From: sashiko-bot@kernel.org
To: "Yuyang Huang" <yuyanghuang@google.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v2 1/2] bpf: reject BPF_PROG_QUERY with short uattr size
Date: Sun, 31 May 2026 00:59:31 +0000 [thread overview]
Message-ID: <20260531005931.D4F201F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260531004748.3567875-2-yuyanghuang@google.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Critical] The patch unconditionally rejects BPF_PROG_QUERY requests with a smaller attribute size, breaking backward compatibility for older userspace applications.
- [Low] Returning -EFAULT for a structure size mismatch is semantically incorrect.
--
commit 205b70f382d21dfafc18f8275384ff0f06e59f6e
Author: Yuyang Huang <yuyanghuang@google.com>
bpf: reject BPF_PROG_QUERY with short uattr size
This commit modifies bpf_prog_query() to return an error if the user-provided
attribute size is smaller than the offset of the query.revision field. This
aims to prevent an out-of-bounds write to userspace.
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index 9e91fb2fb492c..4dbf53e81a38c 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -4719,8 +4719,10 @@ static int bpf_prog_detach(const union bpf_attr *attr)
> #define BPF_PROG_QUERY_LAST_FIELD query.revision
>
> static int bpf_prog_query(const union bpf_attr *attr,
> - union bpf_attr __user *uattr)
> + union bpf_attr __user *uattr, u32 uattr_size)
> {
> + if (uattr_size < offsetofend(union bpf_attr, query.revision))
[Severity: Critical]
Does this unconditionally reject older userspace applications that pass a
smaller uattr_size? The BPF syscall generally maintains backward
compatibility by allowing older binaries to pass smaller structures.
By rejecting the call entirely at the top-level dispatcher, wouldn't this
break ABI for all attachment types (like BPF_FLOW_DISSECTOR), even if those
specific handlers never attempt to write to query.revision?
Could we instead pass uattr_size down to the lower-level query handlers and
conditionally skip writing the revision field to user space when the provided
buffer size is insufficient?
> + return -EFAULT;
[Severity: Low]
Is -EFAULT the correct error code for a structure size mismatch?
Standard practice usually returns -EINVAL (or -E2BIG) for mismatched or
inadequate sizes. -EFAULT typically indicates an invalid memory address
during a copy operation, which might mislead userspace developers trying to
debug their applications.
> if (!bpf_net_capable())
> return -EPERM;
> if (CHECK_ATTR(BPF_PROG_QUERY))
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260531004748.3567875-1-yuyanghuang@google.com?part=1
next prev parent reply other threads:[~2026-05-31 0:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-31 0:47 [PATCH bpf-next v2 0/2] bpf: Align syscall writeback behavior with user-declared size Yuyang Huang
2026-05-31 0:47 ` [PATCH bpf-next v2 1/2] bpf: reject BPF_PROG_QUERY with short uattr size Yuyang Huang
2026-05-31 0:59 ` sashiko-bot [this message]
2026-05-31 3:01 ` Alexei Starovoitov
2026-05-31 3:12 ` Yuyang Huang
2026-05-31 0:47 ` [PATCH bpf-next v2 2/2] selftests/bpf: add verification for BPF_PROG_QUERY attr size boundaries Yuyang Huang
2026-05-31 1:11 ` sashiko-bot
2026-05-31 1:44 ` Yuyang Huang
2026-05-31 1:28 ` bot+bpf-ci
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260531005931.D4F201F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=yuyanghuang@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox