All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Maciej Żenczykowski" <maze@google.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next 2/2] selftests/bpf: Add tests for bpf_sockopt is_compat field
Date: Fri, 14 Aug 2026 11:20:58 +0000	[thread overview]
Message-ID: <20260814112058.A34C61F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260813112039.247862-2-maze@google.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Reading the 4-byte padding at offset 44 in `struct bpf_sockopt` triggers a `verifier_bug` WARN_ONCE because `cg_sockopt_convert_ctx_access()` lacks a translation case.
- [Low] The `getsockopt: read ctx->is_compat` selftest omits the `.io_uring_support = true` flag, reducing test coverage.
--

--- Patch [2]: [PATCH bpf-next 2/2] selftests/bpf: Add tests for bpf_sockopt is_compat field ---
commit 007892bbe60c0ee959b9f1a3e6944cb7ea0af571
Author: Maciej Żenczykowski <maze@google.com>

selftests/bpf: Add tests for bpf_sockopt is_compat field

Sync tools/include/uapi/linux/bpf.h with the addition of the is_compat
field in struct bpf_sockopt and add test cases to prog_tests/sockopt.c
to verify context access permissions.

> diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
> index ffd96e8b920bd..15f712b5b1645 100644
> --- a/tools/include/uapi/linux/bpf.h
> +++ b/tools/include/uapi/linux/bpf.h
> @@ -7616,6 +7616,7 @@ struct bpf_sockopt {
>  	__s32	optname;
>  	__s32	optlen;
>  	__s32	retval;
> +	__s32	is_compat;
>  };

[Severity: High]
Does this addition leave a 4-byte padding at offset 44 that causes a
verifier bug?

Because struct bpf_sockopt contains 64-bit pointers, adding is_compat
makes the fields 44 bytes, expanding the struct size to 48 bytes due to
alignment padding.

In kernel/bpf/cgroup.c, cg_sockopt_is_valid_access() permits accesses up to
the full struct size (48 bytes):

	if (off < 0 || off >= sizeof(struct bpf_sockopt))
		return false;

However, cg_sockopt_convert_ctx_access() lacks a translation case for this
implicit padding at offset 44. If a BPF program reads offset 44, it yields 0
instructions, forcing bpf_convert_ctx_accesses() to emit a verifier_bug
WARN_ONCE.

> diff --git a/tools/testing/selftests/bpf/prog_tests/sockopt.c b/tools/testing/selftests/bpf/prog_tests/sockopt.c
> index eaac83a7f388b..c7dd22d0e3f84 100644
> --- a/tools/testing/selftests/bpf/prog_tests/sockopt.c
> +++ b/tools/testing/selftests/bpf/prog_tests/sockopt.c
> @@ -215,6 +215,49 @@ static struct sockopt_test {
[ ... ]
> +	{
> +		.descr = "getsockopt: read ctx->is_compat",
> +		.insns = {
[ ... ]
> +		},
> +		.attach_type = BPF_CGROUP_GETSOCKOPT,
> +		.expected_attach_type = BPF_CGROUP_GETSOCKOPT,
> +
> +		.get_level = SOL_IP,
> +		.get_optname = IP_TOS,
> +		.get_optlen = 1,
> +	},

[Severity: Low]
Should this test case include the .io_uring_support = true flag?

The "setsockopt: read ctx->is_compat" test configuration further down includes
this flag, but it is omitted here. Adding it would validate io_uring execution
on the new getsockopt hook.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260813112039.247862-1-maze@google.com?part=2

  parent reply	other threads:[~2026-08-14 11:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-13 11:20 [PATCH bpf-next 1/2] bpf: Support cgroup {get,set}sockopt hooks for compat syscalls Maciej Żenczykowski
2026-08-13 11:20 ` [PATCH bpf-next 2/2] selftests/bpf: Add tests for bpf_sockopt is_compat field Maciej Żenczykowski
2026-08-13 12:14   ` bot+bpf-ci
2026-08-14 11:20   ` sashiko-bot [this message]
2026-08-13 12:59 ` [PATCH bpf-next 1/2] bpf: Support cgroup {get,set}sockopt hooks for compat syscalls 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=20260814112058.A34C61F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=maze@google.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.