Netdev List
 help / color / mirror / Atom feed
From: Sechang Lim <rhkrqnwk98@gmail.com>
To: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <martin.lau@linux.dev>
Cc: "David S . Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@kernel.org>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Simon Horman" <horms@kernel.org>,
	"Jamal Hadi Salim" <jhs@mojatatu.com>,
	"Jiri Pirko" <jiri@resnulli.us>,
	"Amery Hung" <ameryhung@gmail.com>,
	"Cong Wang" <xiyou.wangcong@gmail.com>,
	"Toke Høiland-Jørgensen" <toke@redhat.com>,
	"D . Wythe" <alibuda@linux.alibaba.com>,
	"Dust Li" <dust.li@linux.alibaba.com>,
	"Sidraya Jayagond" <sidraya@linux.ibm.com>,
	"Mahanta Jambigi" <mjambigi@linux.ibm.com>,
	"Tony Lu" <tonylu@linux.alibaba.com>,
	"Wen Gu" <guwen@linux.alibaba.com>,
	"David Vernet" <void@manifault.com>,
	bpf@vger.kernel.org, netdev@vger.kernel.org,
	linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org
Subject: [PATCH bpf 1/3] bpf: Reject sleepable programs in bpf-tcp-cc
Date: Tue, 24 Nov 2026 14:31:13 +0000	[thread overview]
Message-ID: <20261124143123.1182108-2-rhkrqnwk98@gmail.com> (raw)
In-Reply-To: <20261124143123.1182108-1-rhkrqnwk98@gmail.com>

A bpf-tcp-cc program can be loaded with BPF_F_SLEEPABLE, but the TCP
stack calls the congestion control ops in atomic context. For example,
tcp_set_ca_state() is called from tcp_v4_syn_recv_sock() in softirq with
the socket spinlock held.

bpf_tcp_congestion_ops has no check_member, so nothing rejects such a
program. Add one that rejects sleepable programs.

Fixes: 1e12d3ef47d2 ("bpf: Allow BPF_PROG_TYPE_STRUCT_OPS programs to be sleepable")
Signed-off-by: Sechang Lim <rhkrqnwk98@gmail.com>
---
 net/ipv4/bpf_tcp_ca.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/net/ipv4/bpf_tcp_ca.c b/net/ipv4/bpf_tcp_ca.c
index 2a71dc81562f..acd5e84a3dd9 100644
--- a/net/ipv4/bpf_tcp_ca.c
+++ b/net/ipv4/bpf_tcp_ca.c
@@ -208,6 +208,16 @@ static const struct bpf_verifier_ops bpf_tcp_ca_verifier_ops = {
 	.btf_struct_access	= bpf_tcp_ca_btf_struct_access,
 };
 
+static int bpf_tcp_ca_check_member(const struct btf_type *t,
+				   const struct btf_member *member,
+				   const struct bpf_prog *prog)
+{
+	if (prog->sleepable)
+		return -EINVAL;
+
+	return 0;
+}
+
 static int bpf_tcp_ca_init_member(const struct btf_type *t,
 				  const struct btf_member *member,
 				  void *kdata, const void *udata)
@@ -335,6 +345,7 @@ static struct bpf_struct_ops bpf_tcp_congestion_ops = {
 	.reg = bpf_tcp_ca_reg,
 	.unreg = bpf_tcp_ca_unreg,
 	.update = bpf_tcp_ca_update,
+	.check_member = bpf_tcp_ca_check_member,
 	.init_member = bpf_tcp_ca_init_member,
 	.init = bpf_tcp_ca_init,
 	.validate = bpf_tcp_ca_validate,
-- 
2.56.1


  reply	other threads:[~2026-11-24 14:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 14:31 [PATCH bpf 0/3] bpf: Reject sleepable struct_ops programs in atomic context Sechang Lim
2026-11-24 14:31 ` Sechang Lim [this message]
2026-11-24 14:31 ` [PATCH bpf 2/3] bpf: net_sched: Reject sleepable programs in bpf qdisc Sechang Lim
2026-11-24 14:31 ` [PATCH bpf 3/3] net/smc: bpf: Reject sleepable programs in smc_hs_ctrl Sechang Lim

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=20261124143123.1182108-2-rhkrqnwk98@gmail.com \
    --to=rhkrqnwk98@gmail.com \
    --cc=alibuda@linux.alibaba.com \
    --cc=ameryhung@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=dust.li@linux.alibaba.com \
    --cc=edumazet@kernel.org \
    --cc=guwen@linux.alibaba.com \
    --cc=horms@kernel.org \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mjambigi@linux.ibm.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sidraya@linux.ibm.com \
    --cc=toke@redhat.com \
    --cc=tonylu@linux.alibaba.com \
    --cc=void@manifault.com \
    --cc=xiyou.wangcong@gmail.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