Skip to content

Commit 37eacb9

Browse files
aspskborkmann
authored andcommitted
bpf: Fix a verifier verbose message
Long ago a map file descriptor in a pseudo ldimm64 instruction could only be present as an immediate value insn[0].imm, and thus this value was used in a verbose verifier message printed when the file descriptor wasn't valid. Since addition of BPF_PSEUDO_MAP_IDX_VALUE/BPF_PSEUDO_MAP_IDX the insn[0].imm field can also contain an index pointing to the file descriptor in the attr.fd_array array. However, if the file descriptor is invalid, the verifier still prints the verbose message containing value of insn[0].imm. Patch the verifier message to always print the actual file descriptor value. Fixes: 387544b ("bpf: Introduce fd_idx") Signed-off-by: Anton Protopopov <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Daniel Borkmann <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 6648e61 commit 37eacb9

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

kernel/bpf/verifier.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18289,8 +18289,7 @@ static int resolve_pseudo_ldimm64(struct bpf_verifier_env *env)
1828918289
f = fdget(fd);
1829018290
map = __bpf_map_get(f);
1829118291
if (IS_ERR(map)) {
18292-
verbose(env, "fd %d is not pointing to valid bpf_map\n",
18293-
insn[0].imm);
18292+
verbose(env, "fd %d is not pointing to valid bpf_map\n", fd);
1829418293
return PTR_ERR(map);
1829518294
}
1829618295

0 commit comments

Comments
 (0)