* [PATCH bpf] bpf: propagate kvmemdup_bpfptr errors from bpf_prog_verify_signature
@ 2026-03-21 6:08 Weixie Cui
2026-03-21 9:11 ` Jiri Olsa
2026-03-24 16:24 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Weixie Cui @ 2026-03-21 6:08 UTC (permalink / raw)
To: ast, daniel, john.fastabend, andrii, martin.lau, eddyz87, song,
yonghong.song, kpsingh, sdf, haoluo, jolsa
Cc: bpf, linux-kernel, Weixie Cui
From: Weixie Cui <cuiweixie@gmail.com>
kvmemdup_bpfptr() returns -EFAULT when the user pointer cannot be
copied, and -ENOMEM on allocation failure. The error path always
returned -ENOMEM, misreporting bad addresses as out-of-memory.
Return PTR_ERR(sig) so user space gets the correct errno.
Signed-off-by: Weixie Cui <cuiweixie@gmail.com>
---
kernel/bpf/syscall.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 274039e36465..51ade3cde8bb 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -2832,7 +2832,7 @@ static int bpf_prog_verify_signature(struct bpf_prog *prog, union bpf_attr *attr
sig = kvmemdup_bpfptr(usig, attr->signature_size);
if (IS_ERR(sig)) {
bpf_key_put(key);
- return -ENOMEM;
+ return PTR_ERR(sig);
}
bpf_dynptr_init(&sig_ptr, sig, BPF_DYNPTR_TYPE_LOCAL, 0,
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH bpf] bpf: propagate kvmemdup_bpfptr errors from bpf_prog_verify_signature
2026-03-21 6:08 [PATCH bpf] bpf: propagate kvmemdup_bpfptr errors from bpf_prog_verify_signature Weixie Cui
@ 2026-03-21 9:11 ` Jiri Olsa
2026-03-24 16:24 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Jiri Olsa @ 2026-03-21 9:11 UTC (permalink / raw)
To: Weixie Cui
Cc: ast, daniel, john.fastabend, andrii, martin.lau, eddyz87, song,
yonghong.song, kpsingh, sdf, haoluo, bpf, linux-kernel,
Weixie Cui
On Sat, Mar 21, 2026 at 02:08:00PM +0800, Weixie Cui wrote:
> From: Weixie Cui <cuiweixie@gmail.com>
>
> kvmemdup_bpfptr() returns -EFAULT when the user pointer cannot be
> copied, and -ENOMEM on allocation failure. The error path always
> returned -ENOMEM, misreporting bad addresses as out-of-memory.
>
> Return PTR_ERR(sig) so user space gets the correct errno.
>
> Signed-off-by: Weixie Cui <cuiweixie@gmail.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
jirka
> ---
> kernel/bpf/syscall.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index 274039e36465..51ade3cde8bb 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -2832,7 +2832,7 @@ static int bpf_prog_verify_signature(struct bpf_prog *prog, union bpf_attr *attr
> sig = kvmemdup_bpfptr(usig, attr->signature_size);
> if (IS_ERR(sig)) {
> bpf_key_put(key);
> - return -ENOMEM;
> + return PTR_ERR(sig);
> }
>
> bpf_dynptr_init(&sig_ptr, sig, BPF_DYNPTR_TYPE_LOCAL, 0,
> --
> 2.39.5 (Apple Git-154)
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf] bpf: propagate kvmemdup_bpfptr errors from bpf_prog_verify_signature
2026-03-21 6:08 [PATCH bpf] bpf: propagate kvmemdup_bpfptr errors from bpf_prog_verify_signature Weixie Cui
2026-03-21 9:11 ` Jiri Olsa
@ 2026-03-24 16:24 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-03-24 16:24 UTC (permalink / raw)
To: Weixie Cui
Cc: ast, daniel, john.fastabend, andrii, martin.lau, eddyz87, song,
yonghong.song, kpsingh, sdf, haoluo, jolsa, bpf, linux-kernel,
cuiweixie
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:
On Sat, 21 Mar 2026 14:08:00 +0800 you wrote:
> From: Weixie Cui <cuiweixie@gmail.com>
>
> kvmemdup_bpfptr() returns -EFAULT when the user pointer cannot be
> copied, and -ENOMEM on allocation failure. The error path always
> returned -ENOMEM, misreporting bad addresses as out-of-memory.
>
> Return PTR_ERR(sig) so user space gets the correct errno.
>
> [...]
Here is the summary with links:
- [bpf] bpf: propagate kvmemdup_bpfptr errors from bpf_prog_verify_signature
https://git.kernel.org/bpf/bpf-next/c/ad2f7ed0ee91
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-24 16:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-21 6:08 [PATCH bpf] bpf: propagate kvmemdup_bpfptr errors from bpf_prog_verify_signature Weixie Cui
2026-03-21 9:11 ` Jiri Olsa
2026-03-24 16:24 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox