From: sashiko-bot@kernel.org
To: "Chengyu Liu" <lui2012qwq@gmail.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH] PCI: endpoint: pci-epf-ntb: cancel cmd_handler synchronously on cleanup
Date: Tue, 03 Nov 2026 16:28:47 +0000 [thread overview]
Message-ID: <sashiko-outbox-195726@kernel.org> (raw)
In-Reply-To: <20261103161622.1597925-1-lui2012qwq@gmail.com>
> epf_ntb_cmd_handler() re-arms itself unconditionally every 5ms at
> reset_handler, with no guard at all. epf_ntb_epc_cleanup_interface()
> uses cancel_delayed_work(), which cannot stop a running callback: if
> the cleanup (configfs unbind) happens while the handler is mid-flight,
> the handler re-arms, and the delayed work fires after the devm-managed
> ntb_epc - and the devm_ioremap'd ntb_epc->reg it dereferences - have
> been released. Use-after-free.
>
> The per-attempt race window is small (sub-microsecond callback vs a 5ms
> period), but configfs bind/unbind cycles can simply be repeated (root)
> until the race is won.
>
> Use cancel_delayed_work_sync(), which waits for a running callback and
> prevents its re-arm from taking effect.
>
> Found by static analysis. The race was reproduced on a KASAN build
> with a small module exercising this exact arm/cancel/free pattern
> (no NTB hardware available); PoC and splat are below.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Chengyu Liu <lui2012qwq@gmail.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261103161622.1597925-1-lui2012qwq@gmail.com?part=1
prev parent reply other threads:[~2026-11-03 16:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 16:16 [PATCH] PCI: endpoint: pci-epf-ntb: cancel cmd_handler synchronously on cleanup Chengyu Liu
2026-11-03 16:28 ` sashiko-bot [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=sashiko-outbox-195726@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lui2012qwq@gmail.com \
--cc=sashiko-reviews@lists.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