Skip to content

lsm,bpf: fix security_bpf_prog_load() error handling#12169

Open
kernel-patches-daemon-bpf[bot] wants to merge 1 commit into
bpf-next_basefrom
series/1099848=>bpf-next
Open

lsm,bpf: fix security_bpf_prog_load() error handling#12169
kernel-patches-daemon-bpf[bot] wants to merge 1 commit into
bpf-next_basefrom
series/1099848=>bpf-next

Conversation

@kernel-patches-daemon-bpf
Copy link
Copy Markdown

Pull request for series with
subject: lsm,bpf: fix security_bpf_prog_load() error handling
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1099848

@kernel-patches-daemon-bpf
Copy link
Copy Markdown
Author

Upstream branch: b1fcdf9
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1099848
version: 1

@kernel-patches-review-bot
Copy link
Copy Markdown

commit a03af62bb4a3613aadacc8cb75f0007d761e785a
Author: Paul Moore <paul@paul-moore.com>

lsm,bpf: fix security_bpf_prog_load() error handling

This commit fixes the error handling in bpf_prog_load() to avoid calling
security_bpf_prog_free() when security_bpf_prog_load() fails. The LSM
handles cleanup of partial state before returning with an error.

Cc: bpf@vger.kernel.org
Cc: linux-security-module@vger.kernel.org

> commit a03af62bb4a3613aadacc8cb75f0007d761e785a
> Author: Paul Moore <paul@paul-moore.com>
> Date:   Sat May 23 12:00:26 2026 -0400
>
>     lsm,bpf: fix security_bpf_prog_load() error handling
>
>     If security_bpf_prog_load() fails there is no need to call into
>     security_bpf_prog_free() as the LSM will handle the cleanup of any partial
>     LSM state before returning to the caller with an error.  Thankfully this
>     isn't an issue with any of the existing code as the LSMs which currently
>     provide BPF hook callback implementations don't allocate any internal
>     state, but this is something we want to fix for potential future users.
>
>     Cc: bpf@vger.kernel.org
>     Cc: linux-security-module@vger.kernel.org
>     Signed-off-by: Paul Moore <paul@paul-moore.com>

This looks like a bug fix for the error handling logic introduced in
commit b3beebbe6154 which imported the kernel/bpf/syscall.c file with
incorrect error handling for security_bpf_prog_load() failure. Should
this include:

  Fixes: b3beebbe6154 ("adding ci files")



AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

In-Reply-To-Subject: lsm,bpf: fix security_bpf_prog_load() error handling
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/26337503379

@kernel-patches-daemon-bpf
Copy link
Copy Markdown
Author

@kernel-patches-daemon-bpf
Copy link
Copy Markdown
Author

Upstream branch: eb19eea
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1099848
version: 1

@kernel-patches-daemon-bpf
Copy link
Copy Markdown
Author

Upstream branch: 8496d90
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1099848
version: 1

If security_bpf_prog_load() fails there is no need to call into
security_bpf_prog_free() as the LSM will handle the cleanup of any partial
LSM state before returning to the caller with an error.  Thankfully this
isn't an issue with any of the existing code as the LSMs which currently
provide BPF hook callback implementations don't allocate any internal
state, but this is something we want to fix for potential future users.

Cc: bpf@vger.kernel.org
Cc: linux-security-module@vger.kernel.org
Signed-off-by: Paul Moore <paul@paul-moore.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant