From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: <chenyuan_fl@163.com>, <daniel@iogearbox.net>, <bpf@vger.kernel.org>
Cc: <yonghong.song@linux.dev>, <andrii@kernel.org>,
<eddyz87@gmail.com>, <memxor@gmail.com>, <martin.lau@linux.dev>,
<song@kernel.org>, <jolsa@kernel.org>, <ihor.solodrai@linux.dev>,
<linux-kernel@vger.kernel.org>,
<linux-trace-kernel@vger.kernel.org>,
"Yuan Chen" <chenyuan@kylinos.cn>
Subject: Re: [PATCH] bpf: Claim the per-CPU send_signal irq_work before filling it
Date: Fri, 02 Oct 2026 11:32:13 +0000 [thread overview]
Message-ID: <DLUBI6OS1J07.Z498VKY5084C@gmail.com> (raw)
In-Reply-To: <20260928081144.207908-1-chenyuan_fl@163.com>
On Mon, Sep 28, 2026 at 04:11 PM chenyuan_fl@163.com <chenyuan_fl@163.com> wrote:
> irq_work_is_busy() cannot see the per-CPU send_signal_work while
> it is being filled: the check only matches after irq_work_queue()
> has claimed the work. An NMI interrupting the fill therefore passes
> it, both callers race for the same irq_work, and the loser's signal
> is silently lost along with its task reference while the queued
> work runs with a mix of both callers' fields.
kprobe, tracepoint and perf_event progs exclude each other on a cpu
via bpf_prog_active, so one of the two progs has to be raw_tp or fentry.
And since commit 87c544108b61 ("bpf: Send signals asynchronously if
!preemptible") this path runs with irqs enabled too, so hard irq
can do the same. Not only NMI.
Pls describe it in the commit log.
Did you reproduce it or was it found by code inspection?
> struct send_signal_irq_work {
> struct irq_work irq_work;
> + /* Covers the fill-to-run span which irq_work_is_busy() cannot see. */
> + atomic_t claimed;
> struct task_struct *task;
can work->task be the claim ?
cmpxchg(&work->task, NULL, task) instead of irq_work_is_busy() and
set it back to NULL at the end of do_bpf_send_signal().
Then no need for extra field.
> - irq_work_queue(&work->irq_work);
> + if (unlikely(!irq_work_queue(&work->irq_work))) {
> + /* Unreachable while the claim is held. */
> + put_task_struct(task);
> + atomic_set_release(&work->claimed, 0);
> + return -EBUSY;
> + }
Drop this hunk. It's dead code.
irq_work_queue() fails only when IRQ_WORK_PENDING is set.
irq_work_single() clears it before calling do_bpf_send_signal()
and the claim is released at the end of it.
bpf_mmap_unlock_mm() doesn't check it either after
commit fa9dcacdcdf4 ("bpf: Fix mmap_lock leak in irq_work path").
Pls tag the respin as [PATCH v2 bpf-next].
pw-bot: cr
prev parent reply other threads:[~2026-10-02 11:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-28 8:11 chenyuan_fl
2026-09-28 9:05 ` bot+bpf-ci
2026-10-02 11:32 ` Alexei Starovoitov [this message]
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=DLUBI6OS1J07.Z498VKY5084C@gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=chenyuan@kylinos.cn \
--cc=chenyuan_fl@163.com \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=ihor.solodrai@linux.dev \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=song@kernel.org \
--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
all inboxes | Powered by JetHome®