* [PATCH bpf 0/3] bpf: Reject sleepable struct_ops programs in atomic context
@ 2026-11-24 14:31 Sechang Lim
2026-11-24 14:31 ` [PATCH bpf 1/3] bpf: Reject sleepable programs in bpf-tcp-cc Sechang Lim
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Sechang Lim @ 2026-11-24 14:31 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau
Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Jamal Hadi Salim, Jiri Pirko, Amery Hung, Cong Wang,
Toke Høiland-Jørgensen, D . Wythe, Dust Li,
Sidraya Jayagond, Mahanta Jambigi, Tony Lu, Wen Gu, David Vernet,
bpf, netdev, linux-rdma, linux-s390
Any struct_ops program can be loaded as sleepable, and it is up to each
struct_ops to reject that in check_member for members that run in
atomic context. tcp_congestion_ops, Qdisc_ops and smc_hs_ctrl have no
check_member, although the kernel calls their members in softirq, under
a spinlock or under rcu_read_lock(). A sleepable program attached there
is entered through __bpf_prog_enter_sleepable(), and lockdep reports
"BUG: Invalid wait context" at its might_fault().
This series adds a check_member that rejects sleepable programs to each
of them, like bpf_tcp_ops does.
Sechang Lim (3):
bpf: Reject sleepable programs in bpf-tcp-cc
bpf: net_sched: Reject sleepable programs in bpf qdisc
net/smc: bpf: Reject sleepable programs in smc_hs_ctrl
net/ipv4/bpf_tcp_ca.c | 11 +++++++++++
net/sched/bpf_qdisc.c | 11 +++++++++++
net/smc/smc_hs_bpf.c | 11 +++++++++++
3 files changed, 33 insertions(+)
--
2.56.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH bpf 1/3] bpf: Reject sleepable programs in bpf-tcp-cc
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
2026-11-24 14:31 ` [PATCH bpf 2/3] bpf: net_sched: Reject sleepable programs in bpf qdisc Sechang Lim
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Sechang Lim @ 2026-11-24 14:31 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau
Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Jamal Hadi Salim, Jiri Pirko, Amery Hung, Cong Wang,
Toke Høiland-Jørgensen, D . Wythe, Dust Li,
Sidraya Jayagond, Mahanta Jambigi, Tony Lu, Wen Gu, David Vernet,
bpf, netdev, linux-rdma, linux-s390
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH bpf 2/3] bpf: net_sched: Reject sleepable programs in bpf qdisc
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 ` [PATCH bpf 1/3] bpf: Reject sleepable programs in bpf-tcp-cc Sechang Lim
@ 2026-11-24 14:31 ` Sechang Lim
2026-11-24 14:31 ` [PATCH bpf 3/3] net/smc: bpf: Reject sleepable programs in smc_hs_ctrl Sechang Lim
2026-11-24 14:38 ` [PATCH bpf 0/3] bpf: Reject sleepable struct_ops programs in atomic context sashiko-bot
3 siblings, 0 replies; 5+ messages in thread
From: Sechang Lim @ 2026-11-24 14:31 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau
Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Jamal Hadi Salim, Jiri Pirko, Amery Hung, Cong Wang,
Toke Høiland-Jørgensen, D . Wythe, Dust Li,
Sidraya Jayagond, Mahanta Jambigi, Tony Lu, Wen Gu, David Vernet,
bpf, netdev, linux-rdma, linux-s390
A bpf qdisc program can be loaded with BPF_F_SLEEPABLE, but enqueue and
dequeue run with the qdisc root lock held and BH disabled.
bpf_Qdisc_ops has no check_member, so nothing rejects such a program.
Add one that rejects sleepable programs.
Fixes: c8240344956e ("bpf: net_sched: Support implementation of Qdisc_ops in bpf")
Signed-off-by: Sechang Lim <rhkrqnwk98@gmail.com>
---
net/sched/bpf_qdisc.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/net/sched/bpf_qdisc.c b/net/sched/bpf_qdisc.c
index 5691c13781a8..3dbe52a04fa2 100644
--- a/net/sched/bpf_qdisc.c
+++ b/net/sched/bpf_qdisc.c
@@ -356,6 +356,16 @@ static const struct bpf_verifier_ops bpf_qdisc_verifier_ops = {
.gen_epilogue = bpf_qdisc_gen_epilogue,
};
+static int bpf_qdisc_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_qdisc_init_member(const struct btf_type *t,
const struct btf_member *member,
void *kdata, const void *udata)
@@ -446,6 +456,7 @@ static struct bpf_struct_ops bpf_Qdisc_ops = {
.reg = bpf_qdisc_reg,
.unreg = bpf_qdisc_unreg,
.validate = bpf_qdisc_validate,
+ .check_member = bpf_qdisc_check_member,
.init_member = bpf_qdisc_init_member,
.init = bpf_qdisc_init,
.name = "Qdisc_ops",
--
2.56.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH bpf 3/3] net/smc: bpf: Reject sleepable programs in smc_hs_ctrl
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 ` [PATCH bpf 1/3] bpf: Reject sleepable programs in bpf-tcp-cc Sechang Lim
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 ` Sechang Lim
2026-11-24 14:38 ` [PATCH bpf 0/3] bpf: Reject sleepable struct_ops programs in atomic context sashiko-bot
3 siblings, 0 replies; 5+ messages in thread
From: Sechang Lim @ 2026-11-24 14:31 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau
Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Jamal Hadi Salim, Jiri Pirko, Amery Hung, Cong Wang,
Toke Høiland-Jørgensen, D . Wythe, Dust Li,
Sidraya Jayagond, Mahanta Jambigi, Tony Lu, Wen Gu, David Vernet,
bpf, netdev, linux-rdma, linux-s390
An smc_hs_ctrl program can be loaded with BPF_F_SLEEPABLE, but
smc_call_hsbpf() calls syn_option and synack_option under
rcu_read_lock().
bpf_smc_hs_ctrl_ops has no check_member, so nothing rejects such a
program. Add one that rejects sleepable programs.
Fixes: 15f295f55656 ("net/smc: bpf: Introduce generic hook for handshake flow")
Signed-off-by: Sechang Lim <rhkrqnwk98@gmail.com>
---
net/smc/smc_hs_bpf.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/net/smc/smc_hs_bpf.c b/net/smc/smc_hs_bpf.c
index 063d23d85850..66cf5143109a 100644
--- a/net/smc/smc_hs_bpf.c
+++ b/net/smc/smc_hs_bpf.c
@@ -82,6 +82,16 @@ static void smc_bpf_hs_ctrl_unreg(void *kdata, struct bpf_link *link)
smc_hs_ctrl_unreg(kdata);
}
+static int smc_bpf_hs_ctrl_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 smc_bpf_hs_ctrl_init_member(const struct btf_type *t,
const struct btf_member *member,
void *kdata, const void *udata)
@@ -130,6 +140,7 @@ static struct bpf_struct_ops bpf_smc_hs_ctrl_ops = {
.unreg = smc_bpf_hs_ctrl_unreg,
.cfi_stubs = &__smc_bpf_hs_ctrl,
.verifier_ops = &smc_bpf_verifier_ops,
+ .check_member = smc_bpf_hs_ctrl_check_member,
.init_member = smc_bpf_hs_ctrl_init_member,
.owner = THIS_MODULE,
};
--
2.56.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH bpf 0/3] bpf: Reject sleepable struct_ops programs in atomic context
2026-11-24 14:31 [PATCH bpf 0/3] bpf: Reject sleepable struct_ops programs in atomic context Sechang Lim
` (2 preceding siblings ...)
2026-11-24 14:31 ` [PATCH bpf 3/3] net/smc: bpf: Reject sleepable programs in smc_hs_ctrl Sechang Lim
@ 2026-11-24 14:38 ` sashiko-bot
3 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-11-24 14:38 UTC (permalink / raw)
To: Sechang Lim
Cc: linux-rdma, linux-s390, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Christian Borntraeger
Sashiko has reviewed this 3-patch series and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124143123.1182108-1-rhkrqnwk98@gmail.com
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-24 14:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH bpf 1/3] bpf: Reject sleepable programs in bpf-tcp-cc Sechang Lim
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
2026-11-24 14:38 ` [PATCH bpf 0/3] bpf: Reject sleepable struct_ops programs in atomic context sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox