From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: 梓川咲太 <inkxiao12@gmail.com>, bpf@vger.kernel.org
Cc: <security@kernel.org>, <kpsingh@kernel.org>, <matt@bobrowski.net>,
<ast@kernel.org>, <daniel@iogearbox.net>, <andrii@kernel.org>,
<stable@vger.kernel.org>
Subject: Re: [PATCH bpf] bpf, lsm: Remove bpf_lsm_release_secctx from sleepable_lsm_hooks
Date: Thu, 19 Nov 2026 06:27:05 +0000 [thread overview]
Message-ID: <DMYZ2PEBP5GQ.NPCWIL8HYD9H@gmail.com> (raw)
In-Reply-To: <CAMcAce8_ZR9xr8KJe6kvDNxr-JW2A5Ya5tn_2SO86hn7oR1KCQ@mail.gmail.com>
On Thu Nov 19, 2026 at 6:18 AM UTC, 梓川咲太 wrote:
> security_release_secctx() invokes release_secctx LSM callbacks
> (selinux_release_secctx() and apparmor_release_secctx()), which only
> kfree(cp->context) and never sleep. Because the hook is non-blocking,
> Netfilter callers legitimately invoke security_release_secctx() under
> atomic, RCU, or softirq context:
>
> 1. net/netfilter/nf_conntrack_standalone.c: ct_seq_start() acquires
> rcu_read_lock() and holds it across ct_seq_show() ->
> ct_show_secctx() -> security_release_secctx(&ctx) until ct_seq_stop().
> 2. net/netfilter/nfnetlink_queue.c: nfqnl_enqueue_packet() runs under
> rcu_read_lock() in packet RX softirq and calls
> nfqnl_build_packet_message(), which allocates with GFP_ATOMIC and
> calls security_release_secctx(&ctx).
> 3. net/netfilter/nf_conntrack_netlink.c: ctnetlink_conntrack_event()
> allocates with GFP_ATOMIC and calls ctnetlink_dump_secctx() ->
> security_release_secctx(&ctx).
>
> Listing BTF_ID(func, bpf_lsm_release_secctx) in sleepable_lsm_hooks
> lets BPF_PROG_TYPE_LSM sleepable programs (lsm.s/release_secctx) call
> blocking helpers/kfuncs such as bpf_copy_from_user() in atomic/RCU/softirq
> context, causing BUG: scheduling while atomic or RCU stalls.
>
> Remove bpf_lsm_release_secctx from sleepable_lsm_hooks. Verified by
> line inspection on 7.4.0-rc3 (20eef29b7c84), 6.12.118 (bpf_lsm.c:347),
> and 6.6.162 (bpf_lsm.c:337), and live QEMU BPF verifier runs on
> x86_64 7.4.0-rc3 and 6.12.118 (lsm.s/release_secctx: LOADED pre-patch ->
> REJECTED post-patch with -EINVAL, "bpf_lsm_release_secctx is not
> sleepable").
>
> Fixes: 423f16108c9d ("bpf: Augment the set of sleepable LSM hooks")
> Cc: stable@vger.kernel.org # 5.10+
> Signed-off-by: BoBppy <inkxiao12@gmail.com>
This is not a real name.
I'm dropping all of your patches.
Teach your bot basics first.
pw-bot: cr
next prev parent reply other threads:[~2026-11-19 6:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 6:18 [PATCH bpf] bpf, lsm: Remove bpf_lsm_release_secctx from sleepable_lsm_hooks 梓川咲太
2026-11-19 6:27 ` Alexei Starovoitov [this message]
2026-11-19 6:40 ` Yingke Xiao
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=DMYZ2PEBP5GQ.NPCWIL8HYD9H@gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=inkxiao12@gmail.com \
--cc=kpsingh@kernel.org \
--cc=matt@bobrowski.net \
--cc=security@kernel.org \
--cc=stable@vger.kernel.org \
/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.