BPF List
 help / color / mirror / Atom feed
From: Mahe Tardy <mahe.tardy@gmail.com>
To: bot+bpf-ci@kernel.org
Cc: bpf@vger.kernel.org, andrii@kernel.org, ast@kernel.org,
	daniel@iogearbox.net, davem@davemloft.net, willemb@google.com,
	eddyz87@gmail.com, edumazet@google.com, john.fastabend@gmail.com,
	kuba@kernel.org, horms@kernel.org, liamwisehart@meta.com,
	martin.lau@linux.dev, pabeni@redhat.com, song@kernel.org,
	netdev@vger.kernel.org, sdf.kernel@gmail.com,
	yonghong.song@linux.dev, jolsa@kernel.org, kuniyu@google.com,
	memxor@gmail.com, emil@etsalapatis.com, almagui@kernel.org,
	martin.lau@kernel.org, mason@kernel.org, ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf-next 7/8] selftests/bpf: Test forbidden bpf_ksock_sendto() LSM attach
Date: Tue, 20 Oct 2026 13:08:24 +0200	[thread overview]
Message-ID: <atdLqLm4HEa1C4SS@gmail.com> (raw)
In-Reply-To: <0f730af064fbd00f1b18405237995d4e78b3672fb4ee14eeaa26784aad4b9228@mail.kernel.org>

On Tue, Oct 20, 2026 at 10:52:16AM +0000, bot+bpf-ci@kernel.org wrote:
> > selftests/bpf: Test forbidden bpf_ksock_sendto() LSM attach
> 
> TL;DR:
> - Selftest calls bpf_ksock_sendto() without a prototype until a later patch,
>   so the test may not build or run here (bisectability)
> - Double blank line nit
> 
> > diff --git a/tools/testing/selftests/bpf/progs/ksock_lsm_verifier.c b/tools/testing/selftests/bpf/progs/ksock_lsm_verifier.c
> > --- a/tools/testing/selftests/bpf/progs/ksock_lsm_verifier.c
> > +++ b/tools/testing/selftests/bpf/progs/ksock_lsm_verifier.c
> > @@ -33,7 +33,26 @@ int BPF_PROG(socket_sendmsg_ksock_send, struct socket *sock, struct msghdr *msg,
> >  }
> >
> >  SEC("lsm.s/socket_sendmsg")
> > -__description("bpf_ksock operations other than send are allowed from socket_sendmsg LSM hook")
> > +__description("bpf_ksock_sendto is rejected from socket_sendmsg LSM hook")
> > +__failure __msg("calling kernel function bpf_ksock_sendto is not allowed")
> > +int BPF_PROG(socket_sendmsg_ksock_sendto, struct socket *sock,
> > +	     struct msghdr *msg, int size, int ret)
> > +{
> > +	struct bpf_ksock *ks;
> > +
> > +	ks = ksock_ctx_get();
> > +	if (!ks)
> > +		return ret;
> > +
> > +	bpf_ksock_sendto(ks, send_data, sizeof(send_data), NULL, 0);
> 
> Is there a BPF-side prototype for bpf_ksock_sendto() at this point in the
> series?
> 
> ksock_common.h declares bpf_ksock_create(), bpf_ksock_connect(),
> bpf_ksock_acquire(), bpf_ksock_release() and bpf_ksock_send() with __ksym,
> and this patch only touches progs/ksock_lsm_verifier.c, so nothing declares
> bpf_ksock_sendto().  vmlinux.h carries types only, not function prototypes.
> 
> With a recent clang this should be a call to an undeclared function, which
> is an error.  With an older clang the call would be emitted as an undefined
> external symbol without __ksym/BTF information, and libbpf would fail to
> open or load the object.
> 
> Either way ksock_lsm_verifier.bpf.o, and therefore RUN_TESTS(ksock_lsm_verifier)
> in prog_tests/ksock.c, would not build or run at this commit, which breaks
> bisectability.
> 
> The declaration is only added by the later patch "selftests/bpf: Test ksock
> sendto()" (65327a57ba55), which adds this to ksock_common.h:
> 
>   int bpf_ksock_sendto(struct bpf_ksock *ks, const void *data, u32 data__sz,
>                        const union bpf_ksock_addr *addr__nullable,
>                        u32 addr__sz) __ksym;
> 
> Could that declaration move into this patch, or this patch be reordered after
> that one?

Yeah I re-ordered the last two patches last minute and forgot about
this.

> 
> > +	bpf_ksock_release(ks);
> > +
> > +	return ret;
> > +}
> > +
> > +
> 
> This isn't a bug, but there are two consecutive blank lines here after
> socket_sendmsg_ksock_sendto(), while the other programs in this file are
> separated by a single blank line (checkpatch --strict reports "Please don't
> use multiple blank lines").  Could one of them be dropped?

sure.

> 
> > +SEC("lsm.s/socket_sendmsg")
> > +__description("bpf_ksock acquire and release are allowed from socket_sendmsg LSM hook")
> >  __success
> >  int BPF_PROG(socket_sendmsg_ksock_allowed, struct socket *sock,
> >  	     struct msghdr *msg, int size, int ret)
> 
> [ ... ]
> 
> > @@ -103,6 +122,7 @@ int BPF_PROG(socket_connect_ksock_allowed, struct socket *sock,
> >  		return ret;
> >
> >  	bpf_ksock_send(ks, send_data, sizeof(send_data));
> > +	bpf_ksock_sendto(ks, send_data, sizeof(send_data), NULL, 0);
> 
> This call to bpf_ksock_sendto() has the same missing-prototype problem
> described above.
> 
> >  	bpf_ksock_release(ks);
> >
> >  	return ret;
> 
> 
> ---
> 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
> 
> CI run summary: https://github.com/kernel-patches/bpf/actions/runs/39408886865


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

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20 10:25 [PATCH bpf-next 0/8] bpf: Expand ksock send-path support Mahe Tardy
2026-10-20 10:25 ` [PATCH bpf-next 1/8] bpf: improve ksock_kfunc_set LSM recursion filter Mahe Tardy
2026-10-20 10:25 ` [PATCH bpf-next 2/8] selftests/bpf: Test allowed bpf_ksock operations at send LSM attach Mahe Tardy
2026-10-20 10:52   ` bot+bpf-ci
2026-10-20 11:06     ` Mahe Tardy
2026-10-20 10:25 ` [PATCH bpf-next 3/8] bpf: move ksock_connect() out of init kfunc set Mahe Tardy
2026-10-20 10:25 ` [PATCH bpf-next 4/8] selftests/bpf: Test verifier filter for ksock connect on LSM attach Mahe Tardy
2026-10-20 10:25 ` [PATCH bpf-next 5/8] selftests/bpf: Test ksock connect/send combinations Mahe Tardy
2026-10-20 10:25 ` [PATCH bpf-next 6/8] bpf: add bpf_ksock_sendto() kfunc Mahe Tardy
2026-10-20 10:25 ` [PATCH bpf-next 7/8] selftests/bpf: Test forbidden bpf_ksock_sendto() LSM attach Mahe Tardy
2026-10-20 10:52   ` bot+bpf-ci
2026-10-20 11:08     ` Mahe Tardy [this message]
2026-10-20 10:25 ` [PATCH bpf-next 8/8] selftests/bpf: Test ksock sendto() Mahe Tardy
2026-10-20 15:07 ` [PATCH bpf-next 0/8] bpf: Expand ksock send-path support Alexei Starovoitov
2026-10-20 15:47   ` Mahe Tardy

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=atdLqLm4HEa1C4SS@gmail.com \
    --to=mahe.tardy@gmail.com \
    --cc=almagui@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bot+bpf-ci@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=eddyz87@gmail.com \
    --cc=edumazet@google.com \
    --cc=emil@etsalapatis.com \
    --cc=horms@kernel.org \
    --cc=ihor.solodrai@linux.dev \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=liamwisehart@meta.com \
    --cc=martin.lau@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mason@kernel.org \
    --cc=memxor@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf.kernel@gmail.com \
    --cc=song@kernel.org \
    --cc=willemb@google.com \
    --cc=yonghong.song@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