Re: [PATCH wpan] ieee802154: look up the wpan_phy dump ifindex in the caller's netns

From: Miquel Raynal

Date: Tue Oct 20 2026 - 04:18:47 EST


On 20/10/2026 at 14:51:25 +08, Maoyi Xie <maoyixie.tju@xxxxxxxxx> wrote:

> nl802154_dump_wpan_phy_parse() looks up NL802154_ATTR_IFINDEX in
> init_net, while the dump only returns phys in the caller's netns. For a
> caller outside init_net, the result depends on what the ifindex is in
> init_net. If no device there has it, the dump returns -ENODEV, even
> when the ifindex is one of the caller's own 802.15.4 interfaces. If an
> 802.15.4 interface there has it, the dump is empty. If any other device
> there has it, the filter is ignored and the dump returns every phy in
> the caller's netns.
>
> GET_WPAN_PHY needs no privilege, so an unprivileged process outside
> init_net can use this to tell which ifindexes exist in init_net.
>
> Look the ifindex up in sock_net(skb->sk), as nl80211_dump_wiphy_parse()
> does. Commit 66e5c2672cd1 ("ieee802154: add netns support") added the
> netns check to the dump loop. It also removed the "TODO netns" comment
> above this lookup but kept init_net.
>
> Fixes: 66e5c2672cd1 ("ieee802154: add netns support")
> Cc: stable@xxxxxxxxxxxxxxx # v4.8+
> Assisted-by: LLM codeql
> Signed-off-by: Maoyi Xie <maoyixie.tju@xxxxxxxxx>
> ---

Seems sensible:

Reviewed-by: Miquel Raynal <miquel.raynal@xxxxxxxxxxx>