From: netdev-bot+sashiko@kernel.org
To: sigefriedhyy@gmail.com
Cc: ajay.kathat@microchip.com, aleksandr.loktionov@intel.com,
andrew+netdev@lunn.ch, claudiu.beznea@tuxon.dev,
davem@davemloft.net, dsahern@kernel.org, donald.hunter@gmail.com,
edumazet@google.com, idosch@nvidia.com, jacob.e.keller@intel.com,
kuba@kernel.org, johannes@sipsolutions.net, kees@kernel.org,
kory.maincent@bootlin.com, kuniyu@google.com,
nicolas.dichtel@6wind.com, nickgarlis@gmail.com,
pabeni@redhat.com, sd@queasysnail.net, shuah@kernel.org,
horms@kernel.org, sdf.kernel@gmail.com,
vadim.fedorenko@linux.dev, willemb@google.com,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-wireless@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH net-next v11 4/6] net: add AF_PACKET multicast dumps
Date: Tue, 13 Oct 2026 02:05:02 +0000 [thread overview]
Message-ID: <179185710223.434549.6133926948819737320@kernel.org> (raw)
In-Reply-To: <20261012011707.3378-5-sigefriedhyy@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] dev_mc_dump() is registered with RTNL_FLAG_DUMP_UNLOCKED.
- [Low] Under this patch alone, the uAPI and the YAML spec disagree.
--
net: add AF_PACKET multicast dumps
This adds an RTM_GETMULTICAST dump handler for ifa_family AF_PACKET. The
handler reports every entry of dev->mc in the ifaddrmsg format, using
IFA_MULTICAST, IFA_MC_USERS and a new IFA_F_GLOBAL bit in IFA_FLAGS. The
dump runs without RTNL, under RCU and netif_addr_lock_bh(), and uses
dev_mc_genid plus dev_base_seq to set NLM_F_DUMP_INTR.
> diff --git a/include/uapi/linux/if_addr.h b/include/uapi/linux/if_addr.h
> index 7fb630b7fe311..0a1ad9ebb47be 100644
> --- a/include/uapi/linux/if_addr.h
> +++ b/include/uapi/linux/if_addr.h
> @@ -57,6 +57,7 @@ enum {
> #define IFA_F_NOPREFIXROUTE 0x200
> #define IFA_F_MCAUTOJOIN 0x400
> #define IFA_F_STABLE_PRIVACY 0x800
> +#define IFA_F_GLOBAL 0x1000
[Severity: Low]
This isn't a bug, but with only this patch applied, the uAPI and
Documentation/netlink/specs/rt-addr.yaml don't match.
The ifa-flags enum in the spec still ends at stable-privacy and has no
entry for IFA_F_GLOBAL.
The getmulticast reply in the spec lists only multicast, mc-users and
cacheinfo. dev_mc_fill_addr() now also emits IFA_FLAGS and
IFA_TARGET_NETNSID.
The dump request attributes in the spec are still empty. The op doc still
covers only IPv4/IPv6.
The next patch in the series, "netlink: specs: rt-addr: document AF_PACKET
multicast dumps", adds the global flag, the flags and target-netnsid
attributes and the AF_PACKET doc. After it, the series is consistent.
Could the spec update be folded into this patch, so the uAPI and the spec
land together?
> diff --git a/net/core/dev_addr_lists.c b/net/core/dev_addr_lists.c
> index 3ab053cbf8b99..d827cc21867bc 100644
> --- a/net/core/dev_addr_lists.c
> +++ b/net/core/dev_addr_lists.c
[ ... ]
> @@ -1215,6 +1219,194 @@ void dev_mc_init(struct net_device *dev)
> }
> EXPORT_SYMBOL(dev_mc_init);
>
> +static int dev_mc_fill_addr(struct sk_buff *skb, const struct net_device *dev,
> + const struct netdev_hw_addr *ha, u32 portid,
> + u32 seq, unsigned int flags, int netnsid)
> +{
[ ... ]
> + if ((netnsid >= 0 &&
> + nla_put_s32(skb, IFA_TARGET_NETNSID, netnsid)) ||
> + nla_put(skb, IFA_MULTICAST, dev->addr_len, ha->addr) ||
[Severity: Medium]
Is it safe to take the IFA_MULTICAST length from the live dev->addr_len
here?
dev_mc_dump() is registered with RTNL_FLAG_DUMP_UNLOCKED. While it calls
this function it holds only RCU and addr_list_lock. Code that writes
addr_len at runtime holds RTNL but not addr_list_lock. One example is
TUNSETLINK in __tun_chr_ioctl():
drivers/net/tun.c:__tun_chr_ioctl() {
...
tun->dev->type = (int) arg;
tun->dev->addr_len = tun_get_addr_len(tun->dev->type);
...
}
Nothing flushes dev->mc when the type changes. Entries added through
SIOCADDMULTI and dev_mc_add_global() remain after the change, because
that path doesn't require IFF_UP.
Those entries were created by __hw_addr_create(), which initializes only
as many bytes as the address length at creation time:
net/core/dev_addr_lists.c:__hw_addr_create() {
...
ha = kmalloc(alloc_size, GFP_ATOMIC);
if (!ha)
return NULL;
memcpy(ha->addr, addr, addr_len);
...
}
Suppose a TAP device is switched from ARPHRD_ETHER (addr_len 6) to
ARPHRD_IP6GRE (addr_len 16). Would this dump then copy the uninitialized
bytes in ha->addr[6..15] to userspace?
There are two related points.
First, if TUNSETLINK runs during a dump, its plain write to dev->addr_len
races with the read here.
Second, in a dump that takes several rounds, entries from the same device
can be emitted with different lengths. A type change doesn't touch
dev_mc_genid or dev_base_seq, so NLM_F_DUMP_INTR isn't set in that case.
dev_mc_seq_show() for /proc/net/dev_mcast already reads dev->addr_len
the same way. This patch adds a second path to existing behavior rather
than a new exposure, but the new uAPI picks up the same problem.
> + nla_put_u32(skb, IFA_MC_USERS, ha->refcount) ||
> + nla_put_u32(skb, IFA_FLAGS, ha->global_use ? IFA_F_GLOBAL : 0)) {
> + nlmsg_cancel(skb, nlh);
> + return -EMSGSIZE;
> + }
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261012011707.3378-1-sigefriedhyy%40gmail.com
next prev parent reply other threads:[~2026-10-13 2:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 1:17 [PATCH net-next v11 0/6] rtnetlink: dump link-layer multicast addresses Yuyang Huang
2026-10-12 1:17 ` [PATCH net-next v11 1/6] netlink: specs: rt-addr: fix the type of target-netnsid Yuyang Huang
2026-10-13 2:04 ` netdev-bot+sashiko
2026-10-12 1:17 ` [PATCH net-next v11 2/6] net: change netdev_hw_addr_list count through helpers Yuyang Huang
2026-10-12 1:17 ` [PATCH net-next v11 3/6] net: add a generation counter for dev->mc changes Yuyang Huang
2026-10-13 2:04 ` netdev-bot+sashiko
2026-10-12 1:17 ` [PATCH net-next v11 4/6] net: add AF_PACKET multicast dumps Yuyang Huang
2026-10-13 2:05 ` netdev-bot+sashiko [this message]
2026-10-12 1:17 ` [PATCH net-next v11 5/6] netlink: specs: rt-addr: document " Yuyang Huang
2026-10-12 1:17 ` [PATCH net-next v11 6/6] selftests: net: test " Yuyang Huang
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=179185710223.434549.6133926948819737320@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=ajay.kathat@microchip.com \
--cc=aleksandr.loktionov@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=claudiu.beznea@tuxon.dev \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=jacob.e.keller@intel.com \
--cc=johannes@sipsolutions.net \
--cc=kees@kernel.org \
--cc=kory.maincent@bootlin.com \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nickgarlis@gmail.com \
--cc=nicolas.dichtel@6wind.com \
--cc=pabeni@redhat.com \
--cc=sd@queasysnail.net \
--cc=sdf.kernel@gmail.com \
--cc=shuah@kernel.org \
--cc=sigefriedhyy@gmail.com \
--cc=vadim.fedorenko@linux.dev \
--cc=willemb@google.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
all inboxes | Powered by JetHome®