Skip to content

Commit 6dae957

Browse files
aspskAlexei Starovoitov
authored andcommitted
bpf: fix possible file descriptor leaks in verifier
The resolve_pseudo_ldimm64() function might have leaked file descriptors when BPF_MAP_TYPE_ARENA was used in a program (some error paths missed a corresponding fdput). Add missing fdputs. v2: remove unrelated changes from the fix Fixes: 6082b6c ("bpf: Recognize addr_space_cast instruction in the verifier.") Signed-off-by: Anton Protopopov <[email protected]> Acked-by: Yonghong Song <[email protected]> Acked-by: Shung-Hsi Yu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 62248b2 commit 6dae957

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

kernel/bpf/verifier.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18379,15 +18379,18 @@ static int resolve_pseudo_ldimm64(struct bpf_verifier_env *env)
1837918379
}
1838018380
if (!env->prog->jit_requested) {
1838118381
verbose(env, "JIT is required to use arena\n");
18382+
fdput(f);
1838218383
return -EOPNOTSUPP;
1838318384
}
1838418385
if (!bpf_jit_supports_arena()) {
1838518386
verbose(env, "JIT doesn't support arena\n");
18387+
fdput(f);
1838618388
return -EOPNOTSUPP;
1838718389
}
1838818390
env->prog->aux->arena = (void *)map;
1838918391
if (!bpf_arena_get_user_vm_start(env->prog->aux->arena)) {
1839018392
verbose(env, "arena's user address must be set via map_extra or mmap()\n");
18393+
fdput(f);
1839118394
return -EINVAL;
1839218395
}
1839318396
}

0 commit comments

Comments
 (0)