From: sashiko-bot@kernel.org
To: "Leon Hwang" <leon.hwang@linux.dev>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next 2/3] bpf: Check tail zero of bpf_prog_info
Date: Wed, 03 Jun 2026 15:14:05 +0000 [thread overview]
Message-ID: <20260603151405.6DB111F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260603144518.67065-3-leon.hwang@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] UAPI regression and fundamentally flawed forward-compatibility logic due to strict zero-checks on previously ignored struct padding.
--
commit 7758939eea6a099c4db0364bf334e0034c2864fc
Author: Leon Hwang <leon.hwang@linux.dev>
bpf: Check tail zero of bpf_prog_info
This commit changes the size passed to bpf_check_uarg_tail_zero() to exclude
the trailing padding of struct bpf_prog_info. The goal is to prevent older
userspace programs from passing uninitialized stack garbage into a future
4-byte field.
Link: https://lore.kernel.org/bpf/20260513224823.6494FC19425@smtp.kernel.org/
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index 1007fb7c87e91..0c86a70d31c17 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -5115,10 +5115,11 @@ static int bpf_prog_get_info_by_fd(struct file *file,
> u32 info_len = attr->info.info_len;
> struct bpf_prog_kstats stats;
> char __user *uinsns;
> - u32 ulen;
> + u32 ulen, len;
> int err;
>
> - err = bpf_check_uarg_tail_zero(USER_BPFPTR(uinfo), sizeof(info), info_len);
> + len = offsetofend(struct bpf_prog_info, attach_btf_id);
> + err = bpf_check_uarg_tail_zero(USER_BPFPTR(uinfo), len, info_len);
[Severity: Critical]
Does this change break the ABI for existing deployed binaries?
Previously, expected_size was 232 (sizeof(info)). If an existing binary
passes info_len = 232 with uninitialized stack garbage in the 4-byte
padding, bpf_check_uarg_tail_zero() would see actual_size <= expected_size
(232 <= 232) and immediately return 0.
By reducing expected_size to 228, actual_size > expected_size (232 > 228),
so bpf_check_uarg_tail_zero() will actively check the 4 padding bytes and
return -E2BIG if they contain garbage. This rejects previously working
applications.
Additionally, does this actually protect against the stated future issue?
If a future kernel adds a new 4-byte field, the struct size stays 232, and
the new kernel's expected_size will be 232. At that point, those old buggy
binaries passing info_len = 232 will once again hit the fast path
(actual_size <= expected_size), skipping the check and allowing the
uninitialized padding to be consumed as the new field.
> if (err)
> return err;
> info_len = min_t(u32, sizeof(info), info_len);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260603144518.67065-1-leon.hwang@linux.dev?part=2
next prev parent reply other threads:[~2026-06-03 15:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 14:45 [PATCH bpf-next 0/3] bpf: Check tail zero of bpf_map_info and bpf_prog_info Leon Hwang
2026-06-03 14:45 ` [PATCH bpf-next 1/3] bpf: Check tail zero of bpf_map_info Leon Hwang
2026-06-03 15:16 ` Mykyta Yatsenko
2026-06-03 14:45 ` [PATCH bpf-next 2/3] bpf: Check tail zero of bpf_prog_info Leon Hwang
2026-06-03 15:14 ` sashiko-bot [this message]
2026-06-04 2:23 ` Leon Hwang
2026-06-03 15:17 ` Mykyta Yatsenko
2026-06-03 15:37 ` bot+bpf-ci
2026-06-04 2:24 ` Leon Hwang
2026-06-03 14:45 ` [PATCH bpf-next 3/3] selftests/bpf: Add tests to verify checking padding bytes for bpf_[map,prog]_info Leon Hwang
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=20260603151405.6DB111F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=leon.hwang@linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/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