]> Git Repo - linux.git/commitdiff
bpf: fix possible file descriptor leaks in verifier
authorAnton Protopopov <[email protected]>
Fri, 29 Mar 2024 07:11:06 +0000 (07:11 +0000)
committerAlexei Starovoitov <[email protected]>
Fri, 29 Mar 2024 16:19:55 +0000 (09:19 -0700)
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: 6082b6c328b5 ("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]>
kernel/bpf/verifier.c

index 353985b2b6a279f0d5a1784d753b10002cfb216e..98188379d5c77d79d3a5e764659ed4426f931d14 100644 (file)
@@ -18379,15 +18379,18 @@ static int resolve_pseudo_ldimm64(struct bpf_verifier_env *env)
                                }
                                if (!env->prog->jit_requested) {
                                        verbose(env, "JIT is required to use arena\n");
+                                       fdput(f);
                                        return -EOPNOTSUPP;
                                }
                                if (!bpf_jit_supports_arena()) {
                                        verbose(env, "JIT doesn't support arena\n");
+                                       fdput(f);
                                        return -EOPNOTSUPP;
                                }
                                env->prog->aux->arena = (void *)map;
                                if (!bpf_arena_get_user_vm_start(env->prog->aux->arena)) {
                                        verbose(env, "arena's user address must be set via map_extra or mmap()\n");
+                                       fdput(f);
                                        return -EINVAL;
                                }
                        }
This page took 0.085663 seconds and 4 git commands to generate.