From: Binbin Deng <18983559317@163.com>
To: netdev@vger.kernel.org
Cc: sam@mendozajonas.com, fercerpav@gmail.com, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
horms@kernel.org, gwshan@linux.vnet.ibm.com, joel@jms.id.au,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v1] net/ncsi: fix use-after-free of ncsi_package in ncsi_remove_package()
Date: Mon, 19 Oct 2026 09:11:22 +0800 [thread overview]
Message-ID: <20261019011122.432381-1-18983559317@163.com> (raw)
In-Reply-To: <20261017012431.413648-1-18983559317@163.com>
Thank you for the review. All four findings are legitimate. This patch is
one of three companion fixes, and none of the Highs is closed by this patch
alone -- v2 will make the dependency explicit in the commit message and fix
the [Low] inaccuracy.
1. [High] "kfree_rcu() only delays the free ... none of the NCSI netlink
walkers enter an RCU read-side critical section"
Agreed. The read side enters rcu_read_lock() in the companion series
"net/ncsi: fix use-after-free of ncsi_channel in ncsi_remove_channel()"
(msgid 20261017024947.420683-1-18983559317@163.com), which wraps the
genl handlers around the device resolution and the list walks, keeping
the genlmsg_new(GFP_KERNEL) of the PKG_INFO doit outside the critical
section. I split free side and read side this way so each object keeps
its own Fixes: tag for -stable backporting; the race is closed by the
union of the series. The vlan fix that was just merged,
9c7e89fc1b68 ("ncsi: Fix use-after-free in the VLAN id list removal"),
shows the free-side-only half: there it was sufficient because the
set_one_vid() reader already held rcu_read_lock(); here no reader does,
so the read-side series is required alongside, and v2 of this patch
will stop implying that a grace period is already relied upon.
2. [High] "The child channels of the package this patch keeps alive are
still freed with no grace period"
Agreed; covered by the same companion series: ncsi_remove_channel()
releases nc->mac_filter.addrs, nc->vlan_filter.vids and nc itself from
an RCU callback, since the readers reach the filter arrays through the
channel (the KASAN report on the dump reader is a "Read of size 2" on
the freed u16 vids[] entries).
3. [High] "The netlink readers hold no reference to the parent
struct ncsi_dev_priv, and the same teardown frees it immediately"
Agreed; covered by the third companion series, "net/ncsi: fix
use-after-free of ncsi_dev_priv in ncsi_unregister_dev()" (msgid
20261017015315.415794-1-18983559317@163.com), whose v2 also quiesces
the channel monitor timers and the 256 request timers before the
removal loop, which is your pre-existing High on that series.
4. [Low] commit message describes the reader inaccurately
Conceded, my mistake: the walker writes the package id with
nla_put_u32(skb, NCSI_PKG_ATTR_ID, np->id);
and never reads np->multi_channel; I had dragged in fields from
ncsi_set_interface_nl()/ncsi_clear_interface_nl(), which are not the
readers raced here. The KASAN report the patch is built on matches
your reading: the "Read of size 1 ... 0 bytes inside of freed 64-byte
region" in ncsi_write_package_info+0xe3c is the u8 np->id load feeding
that nla_put_u32() (sizeof(struct ncsi_package) is 60 bytes, so it
lands in kmalloc-64). v2 corrects the message.
5. Pre-existing High: ncsi_unregister_dev() frees every package and
channel before it stops the work item
Agreed. The worker race is real and kfree_rcu() does not help against
it; it is addressed by disable_work_sync() being moved ahead of the
removal loop in v2 of the ndp companion series, together with the
monitor and request-timer quiescing.
pw-bot: cr
prev parent reply other threads:[~2026-10-19 1:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-17 1:24 [PATCH net v1] net/ncsi: fix use-after-free of ncsi_package in ncsi_remove_package() Binbin Deng
2026-10-18 2:05 ` netdev-bot+sashiko
2026-10-19 1:11 ` Binbin Deng [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=20261019011122.432381-1-18983559317@163.com \
--to=18983559317@163.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fercerpav@gmail.com \
--cc=gwshan@linux.vnet.ibm.com \
--cc=horms@kernel.org \
--cc=joel@jms.id.au \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sam@mendozajonas.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