Article View: linux.kernel.netdev
Article #5323[PATCH wpan] ieee802154: look up the wpan_phy dump ifindex in the caller's netns
From: Maoyi Xie
Date: Tue, 20 Oct 2026 06:51
Date: Tue, 20 Oct 2026 06:51
61 lines
13397 bytes
13397 bytes
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@vger.kernel.org # v4.8+
Assisted-by: LLM codeql
Signed-off-by: Maoyi Xie <maoyixie.tju@gmail.com>
---
I asked about this on linux-wpan and netdev in September [1].
Found with a CodeQL check for lookups done in init_net. Tested on an
unmodified v7.3 and on v7.3 with this patch, in qemu with two
mac802154_hwsim radios and phy1 moved into netns ns1. Not tested on
real 802.15.4 hardware. Dumps from ns1, filtered by ifindex:
ifindex in the filter before fix with fix
4: wpan1 in ns1, unused in init_net -ENODEV phy1
3: wpan0 in init_net, unused in ns1 empty -ENODEV
5: sit0 in init_net, unused in ns1 phy1 -ENODEV
3: wpan0 in init_net, new wpan2 in ns1 empty phy1
Rows 1 to 3 give the same results for uid 65534 in ns1. For uid 65534
in its own user and net namespace, which has no phy, ifindex 3 and 5
return an empty dump before the fix and -ENODEV with it. Unfiltered
dumps and dumps from init_net do not change.
[1] https://lore.kernel.org/all/20260920165057.3753458-1-maoyixie.tju@gmail.com/
net/ieee802154/nl802154.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
index 115f43d0e158..fae5c413fa60 100644
--- a/net/ieee802154/nl802154.c
+++ b/net/ieee802154/nl802154.c
@@ -581,7 +581,7 @@ static int nl802154_dump_wpan_phy_parse(struct sk_buff *skb,
struct cfg802154_registered_device *rdev;
int ifidx = nla_get_u32(tb[NL802154_ATTR_IFINDEX]);
- netdev = __dev_get_by_index(&init_net, ifidx);
+ netdev = __dev_get_by_index(sock_net(skb->sk), ifidx);
if (!netdev)
return -ENODEV;
if (netdev->ieee802154_ptr) {
--
2.34.1
Technical Details
Message-ID:
<20261020065125.896530-1-maoyixie.tju@gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-349067-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-349067-linux-kernel-netdev=dewy.ru
From: maoyixie.tju@gmail.com (Maoyi Xie)
Newsgroups: linux.kernel.netdev
Subject: [PATCH wpan] ieee802154: look up the wpan_phy dump ifindex in the caller's netns
Date: Tue, 20 Oct 2026 14:51:25 +0800
Organization: Usenet Network
Message-ID: <20261020065125.896530-1-maoyixie.tju@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="3797622"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:5Mv0Fgh8m1yw6Tx9FhUzc0fdpCk= sha256:yDklYUxwQ1mKzIC13GHPAq++DpfXS1AxAwbFiFv1FiA=
sha1:J4soyKDfLYB/phrW63an/3i80m4= sha256:90u8ml5tGoY4AYeRM17Ln7ApMQnxcAu0ay37AXB1VUA=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 7C3CD110C1C; Tue, 20 Oct 2026 09:54:39 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id kugsW__kUgdB;
Tue, 20 Oct 2026 09:54:32 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-349067-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id A7891110C19; Tue, 20 Oct 2026 09:54:19 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id 2729C3DABB; Tue, 20 Oct 2026 06:51:37 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1792479095;
b=Z5JmrbmEIT1kw56iMReMnwKIRkj7ZnldNm8qqY5/zRbLV3fkkPNzIpmXNNiqgeNJPTBc
fa+aah9q/azf3a8ESBwLXcx72SpEQCQ4/ZI01w+NtsxaMArr7x+eSulC4rMpD9aYq4dwk
uRYvW/7ETDZ0M2A/ebRg1OWYYyyWsCM2GY7voTmhN3nobkWneuoVJwmBktnSs6y3Im28p
uKdxnQYXJg14a2zysfFAuWvaudQ4B/J3Mu2TSgKv84QwOjJB8QgZOccpgUwHSKgqqCH+T
ScCH3JQxT3HcUFlNG7SJLSh7wvst4UMkXxSMO5JNhYdnkh8Mfyj9y4LWRVOGtbhoyJA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792479095;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:Date:Message-Id:
X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding;
bh=dHQhRD6vyxHfKtcPIP6kj0jtBv/cVh1zjgBd/JhnQeQ=;
b=MaXRV8mT8ErdHchskZgrIaTHmDoQDXWLZQ4trgQdSaED9wlh0+Chtg7DEEI07b5RUBlu
sDqZcwxH2vxbiGWul60YnEw2h/XwaczSaU0XQb31kEcyaYm85xSDgalvGOpPFjG2IfRsg
Umtlh8legcKIXmAQC3nHlryKBeBq5L+dhwjXqmWkOWRbzxMwB1qmBV4urn8y5GrmuVXPL
UpPEuY3lsSCUA6m4BJba63zVRIpR7Y1X70duiWmtwporiwCacQHiZiVMn41Okpr8CtEeb
sLTqnevT/puzU52sbhc6djmFBRqWK4foh0lo5ntQ+girC/L3kvoXg8tWC7GttjF3y+g==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=XlsyYn4Q;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 2F056606A32A;
Tue, 20 Oct 2026 06:51:35 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=XlsyYn4Q
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.50
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1792479094;
b=TBol2bJgfj15QOfeZ4qWlKiEYxnaZm6ZfAJeW6j4SGGNqI7eZ7RhOlnPpbv4ga3cmCBX
6XOwG8vP/81Ea3qgm9ilTa/M3Zza5aKc37pQmyupqQf82pIOHAvoYjP1j/+2OEnZhZXeC
cbWVorEVHxpno62u8HlVouLv2wxOkcM9m4oyllhwI7Z43TcT+j8m/DlmJvmW0yDpzmeEq
j7+n7GFHb4e1CuXWZ2esGCGIp+7u5mcBpdWr9dviJ7RcHjf8APszz6QXG0CoTX8Rnb87U
5L1mQfLrEO4zeHzLzJ5kgCgzzZGXCfnFcGRgenqxVWC7w91SD4HDsFEDY5OpmcSSI/Q==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792479094;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
From:To:Cc:Subject:Date:Message-Id:X-Mailer:MIME-Version:
Content-Transfer-Encoding;
bh=dHQhRD6vyxHfKtcPIP6kj0jtBv/cVh1zjgBd/JhnQeQ=;
b=n3r6PZet2SLZYFjE1Dzs75mkxlMH0ZCQBsl3QeGr9pPOWe0xjQ400CtGWGM8Y3KyCcj6
GOXqIO3GDTTeBuKmdZsqy9sLYoSsEAq5UfJxQiriYhIIHcflHgm4mJgSrXLH7T74fBYYl
SLyZkH9mDohGrUA6Z0IDWFEA51YT8Edh8AcC4D4mAas/OKwXk21TfNnyn94siEApYwEO4
FX9u2PDTiR0yU0vw9q8octtDsQt88ZfQgmpF9LGuDL4g6sB6Thb6pndziQCJPOihApKh6
XCxVOHwf26KLXIzE6Y185nC7nsFtYXxFjbzEb3x0qyUuxhFrBggnr4Q3JW9ipOauhsQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=XlsyYn4Q;
arc=none smtp.remote-ip=209.85.216.50
X-Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF7D4606A31B
for <netdev@vger.kernel.org>; Tue, 20 Oct 2026 06:51:33 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AF7D4606A31B
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-3a0aaa0fd13so2631778a91.2
for <netdev@vger.kernel.org>; Mon, 19 Oct 2026 23:51:33 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1792479093; x=1793083893; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:from:to:cc:subject:date:message-id:reply-to:content-type;
bh=dHQhRD6vyxHfKtcPIP6kj0jtBv/cVh1zjgBd/JhnQeQ=;
b=XlsyYn4QZ5xeFcxfmYe0YJbtBkOtdfi0jehGfY+o5BU0Y74fuNp7fOQIjsX5KqKHMi
BkGGTDd19afZjuMgFZlYCMY2C7cNfgKjiiIN2yfrYPK8sP5OyQ+CuQATH+cZhDlDH7kh
vrv+nGnm9HowpCUXOv7nXl+CAmiPsXMEMAxZxD3L0GP+b55VoxT/MlKYvyg7dU/58Lfa
JFbAwvf0mcc3IYkPykpf0CRH1vK0mf/kFen+cmbfFhaW6VnApk9gwFlVRNO08br0nSx4
/NIA+YcVR4mIvHEfyVrUS2xjEEEniVbgibRLENc3JM9yParehvYI6iGEhfQWo6UVgGok
GD5Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1792479093; x=1793083893;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=dHQhRD6vyxHfKtcPIP6kj0jtBv/cVh1zjgBd/JhnQeQ=;
b=I6WtvxtbCGtAuUaP1tpimfkV+AENgN7xQLcVzowWyCA97S3VMJlOVttZBDlPWrZj21
2Yq2xZw7+vROWZvSCMnVrOl/vdeSKMFMmKwlcBUJjeIXLL8SGCrAuOeJPGicQNPUG5Og
1aN3F5oj01YiFu91IzinNGh0wDLPMcvHgj0jF4ZQ/wV0S9YBRY7jlUnxy3ycAioCga/v
Yw93Fb+bgBl9TSSbNAljk3W8idG5vncdJszUgTBK5e1S5SRONnsqlHlG+etgq+7DKloa
geVjAT5dOV6QJOoww66KzDnJX3Z6LViR3t4AYpy1bn+e3bvY1olJrdUfde5Tx1zp1cwn
KVfg==
X-Forwarded-Encrypted: i=1; AKwUvByRccFfXgHX1vWT25AYqHx49iA0HntaitkQGUFZMTUpSug1GSn5zIk6yOO8cca/v2E4/c6GdT0=@vger.kernel.org
X-Gm-Message-State: AFq9FYIdSsOSt81IiJwLrinswQ+MDTLTeIAIlogO1QoQrw1f5aEE9UvR
BnUWy9GWFFDaxK8JeRywVj+bjQauGHioyFlnmO+wpUe1lTQj+2kWrFom
X-Gm-Gg: AYBFou0kKB0NUn/mRvbfNz+UuMHITrqrDsqbCpu6bdN0yUpKhXV4zE/39HbMlIXtvj6
QH2TE9qqdFNfa9V/WbmtyI/kip+CptE/Zc8/69UHdTPKVhVfXOEcIz1IPJvttVg7UqBUz4gIgiX
qsE9DEUOzTbCiwHywbC3n8pUKOQ1VDm7lzogzLsHN9H4F47A65unFpENaouEQJzQejRx9sfw0Sc
oS++xIyR0gYJzdNEVe6rYmD6ELts3nFgdfAighwYivjgtoDgZTvMDqz8XfAHzRnNnmQmwu4jJp/
/SMOmeCieseMDUDU2AfjWKtlswNf6bT21kBVwLU0P7V55ozCw+L4PFrDUW0XMH10e0JmtLAiYUH
Pohii6fQmQd57Hv8MC6yLUGe7cp0fcWLuFlgxeqcjc+H2U/mB5Mapa0jpfnGJ9SMw143ORV5vYL
kR2SIvg6/xvOgPUYNH5Dp1CDPIxQFcTefZMCDDVGZl4elbBMrkmfB6qjcJ2lV9CWz7OkjMWfJlN
fAyVJVJ3qNCTB2D0Z1AmJRCi0IwvYh9PA==
X-Received: by 2002:a17:90b:3ec5:b0:3ac:adce:60af with SMTP id 98e67ed59e1d1-3aceeb92998mr8773726a91.16.1792479093049;
Mon, 19 Oct 2026 23:51:33 -0700 (PDT)
X-Received: from csl-conti-dell7858.ntu.edu.sg ([155.69.195.57])
by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3ad5d56eddbsm2563561a91.9.2026.10.19.23.51.28
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Mon, 19 Oct 2026 23:51:32 -0700 (PDT)
X-Cc: "David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Marcel Holtmann <marcel@holtmann.org>,
Chandru Gopi <chandru.gopi.dev@gmail.com>,
linux-wpan@vger.kernel.org,
netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
X-Mailer: git-send-email 2.34.1
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list