Article View: linux.kernel.netdev
Article #20934[PATCH net v3] net: zero the tail of ha->addr when allocating address list entries
From: Henry Martin
Date: Mon, 23 Nov 2026 12:13
Date: Mon, 23 Nov 2026 12:13
67 lines
13427 bytes
13427 bytes
__hw_addr_create() allocates entries with kmalloc() and initializes only
addr_len bytes of ha->addr, but the dump paths emit each entry using the
current dev->addr_len, so an entry created with a smaller addr_len is
dumped with an uninitialized tail.
dev->addr_len can grow at runtime and nothing flushes the lists. While
addr_len is 0 every addition collapses into one node, because
__hw_addr_add_ex() compares zero bytes, so the test adds one zero-length
multicast entry to each of 64 tun devices and switches them to
ARPHRD_IP6GRE (addr_len 16). RTM_GETMULTICAST then returned 64 entries
of 16 bytes, 37 with non-zero bytes and 21 starting with a kernel heap
pointer (e.g. 0xffff8188_04857ee0). tun has to flush dev->uc and
dev->mc in TUNSETLINK as well, which is a separate patch; qmi_wwan raw
IP mode and the HDLC attach/detach paths change addr_len in the same
way, so tun is not the only case.
Allocate with kzalloc() so the tail is zeroed at creation; the explicit
ha->sync_cnt = 0 then becomes redundant.
Found by an automated static analysis scan (Tencent CodeBuddy Security)
and triggered at runtime on v7.4-rc3 as an unprivileged user.
Cc: stable@vger.kernel.org
Fixes: cca8ea3b05c9 ("net: tun: set tun->dev->addr_len during TUNSETLINK processing")
Link: https://lore.kernel.org/netdev/20261116024056.1274402-1-bsdhenrymartin@gmail.com/
Link: https://lore.kernel.org/netdev/20261118125443.1137177-1-edumazet@kernel.org/
Reviewed-by: Daniel Machon <daniel.machon@microchip.com>
Reviewed-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
---
v2 -> v3:
- describe the test setup accurately: one entry on each of 64 tun
devices, since all additions collapse into one node while addr_len
is 0
- point Fixes: at cca8ea3b05c9, which made the leak reachable from tun
- link to v1 instead of the earlier review thread, and link to the
companion tun patch
- note that other drivers change addr_len without flushing the lists
- state how the issue was found
net/core/dev_addr_lists.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/dev_addr_lists.c b/net/core/dev_addr_lists.c
index d827cc21867b..9613c8a9ed7f 100644
--- a/net/core/dev_addr_lists.c
+++ b/net/core/dev_addr_lists.c
@@ -96,7 +96,7 @@ __hw_addr_create(const unsigned char *addr, int addr_len,
alloc_size = sizeof(*ha);
if (alloc_size < L1_CACHE_BYTES)
alloc_size = L1_CACHE_BYTES;
- ha = kmalloc(alloc_size, GFP_ATOMIC);
+ ha = kzalloc(alloc_size, GFP_ATOMIC);
if (!ha)
return NULL;
memcpy(ha->addr, addr, addr_len);
@@ -104,7 +104,6 @@ __hw_addr_create(const unsigned char *addr, int addr_len,
ha->refcount = 1;
ha->global_use = global;
ha->synced = sync ? 1 : 0;
- ha->sync_cnt = 0;
return ha;
}
--
2.43.7
Technical Details
Message-ID:
<20261123121325.3137049-1-bsdhenrymartin@gmail.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369305-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369305-linux-kernel-netdev=dewy.ru
From: bsdhenrymartin@gmail.com (Henry Martin)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v3] net: zero the tail of ha->addr when allocating address list entries
Date: Mon, 23 Nov 2026 20:13:25 +0800
Organization: Usenet Network
Message-ID: <20261123121325.3137049-1-bsdhenrymartin@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="3870986"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:wd9tJ2TMOwC4lTNcHYsRrccwgNE= sha256:wJon7z7rN2YT80PA1PJUsfOX95SDspNACavsvEWxWMA=
sha1:NJ8JLKDYd0C9hn3zNak16E0hA/s= sha256:kiv7smIDEjmJ7aiHC+/nTHULHPJDRmla7ZC/Ymdqms4=
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 3F2DA125DAA; Mon, 23 Nov 2026 15:14:03 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 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.249,
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 oIbI1KxJ_BYr;
Mon, 23 Nov 2026 15:13:58 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-369305-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mail.dewy.ru (Postfix) with ESMTPS id 54622125DA6; Mon, 23 Nov 2026 15:13:46 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by tor.lore.kernel.org (Postfix) with ESMTP id B7FF927AEA; Mon, 23 Nov 2026 12:13:43 +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=1795436023;
b=S/siuBfbeKRBkUxkDjA9LRkntCh6gMqtq+BOSpqG6/tZgpftdc3Z/JpTWwvAsnSsNyPr
Vh03ZamQ6uIMZf/KCDobEelXPIjgrCbEmd5ueVV8N0QVOBUY4yPa87mjeRYn9YO2OAxSl
P2TregXIhiVWy5/YyQmDjTvB7ta2h3dW2r6nGJjgY4GlrsOIG7DwUuebfmYatPn/z2M+2
z2r5HKGbRbhqlfJK7iOnArvyUqoVNC9AbKqcrVjwaLKCpPE3TlqAtrjNmVfsUO0I9rABP
BMQ71Fq0wdQkfWfxh9oU6utlZ77D2vc2KbRNbEC/dMgcYTqC5S7I5cqR/nLI1Gj2+Sw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795436023;
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=uZh81Patjg5SXBTd35jRhp7Z8jCjOHuf1P6cwMNCRTo=;
b=itoSGY7l8VJ7hAbLA69gkAR8xC0/nblGiZKHGxf4k0fffxElLkmbgPj7Lxck1NkMkdMK
sRKLy7yOKKvV+L0Ay6tCJOaDDUnf4V1QS28Qzx4gWqdeTFeCXJgXuPw46NZ1rU+gKBNtW
lDT6RpmnQ+JaJti7jszZs897/CkvbaqUhkUf6n/urBYIVNy+eghxOlmm+/ETrohntxy4M
h6C/Vg6N3Py78m2xr9lX9MlX9fcd0HzutnyjryeUwxKLCjcuegDBak+Cwa5lGXfU1NPL9
Z0ZrKygKmEAz0UwCIgsffmnX6Soiw6XvEIH8BMjboG0OGrs85Clp6kddVafZtHF/kRQ==
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=20260707 header.b=GQ8uRzpp;
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 240D7606A31E;
Mon, 23 Nov 2026 12:13:43 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=GQ8uRzpp
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.231.75
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1795436022;
b=ihIZm+jQIMplTjPcikpO7C1ZpNxvHy2O7rFBJS/6sNgzgrhw3nVrzg3YJ8K1K6B5ynCF
iEitslMW6VPd96k7+XPVcaPuh3234eghLIoqnzRQ1Wb4YGFmsulLGgGxCBVC7RpZQ5hvv
PAyzFzM9hzZp0becmIKxnDaF2eVHjVqScQ/O+F7KFvkEw9dt2/h1jXmqnL/dHEWMysRhK
PRpYmcQWs9H/IwsYUTZoNuYN6QRqVBPbs7up3w7I1Y25Y0bO3pbVHZUKR4YnQbKuxs4Jt
bTl715Y4Fknpk8Mi3XAxu5R2u3Ktpmr+ixAdEC4MjvEsCu02hHgtgFzlAlQ46H2gNSg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795436022;
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=uZh81Patjg5SXBTd35jRhp7Z8jCjOHuf1P6cwMNCRTo=;
b=ywlz1rUX5vGfXtpS3ulck/wuPGR5RcCpr1YpTxdQZaNuitL59pmR+gw+QNR1jBcySE7u
c8P5xLBCCJu9FHlaZbY8hUoJ5Ea4FsahOb7D72rZ1Usq9DwtVthhf23EVrOezE1hZhZgR
sag/c0KeCwC60/fR9aaeRiPo2/LjsUReRKcH5BHl3c9XP6++WkBiRk4FdFhHxHhQujA13
znKPn/JffbNkmrdjNaKoHGIeNVx1/a7L4lgI6nCspGX0r54yzZeu6tb9zadrVMPhcpO4I
iAfSsuNfDCAYX/JAvVKhWIcZEdOu87TH4Pe3+U1cANZkaiMt2bSe0M94hl8mciUm0sw==
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=20260707 header.b=GQ8uRzpp;
arc=none smtp.remote-ip=74.125.231.75
X-Received: from mail-oa2-f11.google.com (mail-oa2-f11.google.com [74.125.231.75])
(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 EDF61606A32A
for <netdev@vger.kernel.org>; Mon, 23 Nov 2026 12:13:41 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EDF61606A32A
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-oa2-f11.google.com with SMTP id 586e51a60fabf-462dec1c4c5so1587666fac.0
for <netdev@vger.kernel.org>; Mon, 23 Nov 2026 04:13:41 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1795436021; x=1796040821; 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=uZh81Patjg5SXBTd35jRhp7Z8jCjOHuf1P6cwMNCRTo=;
b=GQ8uRzppCrSAFj/ldXPJN9BOk6XTK11npre3CPqjqxUgfrTJ7bXESlWjA0Do4oOC2X
jBFq36MStqMpQ14eg3YmnN5Q+s0VQKsJSPsE8HR/LFIMXy9ztBSztLC/LUx73FuPfk0u
1IY8ZtqzeXWt8DqHwm0px+gkjtQfNgjKQVFzt7uJLo94dZJxXLo8IhubauZfFhYtulK2
P7kZ5ZGJyxHZab3/GJ+dKUnBy3Wq5i7lqHOen33RODD03/Vu2c5OK3frDRWHrYSVEt0+
2U/eFWqu9dfv1n4dOxqFqiZZ2boqUkI5aXafVvUok2o/HjJcw5h05Yejeq3s1Nd4Svvw
4I3Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1795436021; x=1796040821;
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=uZh81Patjg5SXBTd35jRhp7Z8jCjOHuf1P6cwMNCRTo=;
b=nSzz7yTLfWzwOCwU0Ueuv6Nao/7IseRjPs9gOyQZyj2zL5MBCMCXTkkA2a+xiYXkQg
CR7ZltGPXCqGgymKESdRRd7tL1c88rfJjv8k8ij9Gz+9XA646ME+LTty3lWYs1rQF5U/
6buiM0O2NtU3YLJYNj2dDJwIW8Yg1sUqBGuWxTMWCjztI5I8/W31ANv/MaM2dv6TXl5V
+vf8OErnWZkAvOLp8YeZL7i7X22uaETsVCMZgjo4OWCSv6LmGtVvbBECArwocXxftFOE
X91+ggIMTwN6MvZiQP9wfRqt4isdFf443VxlHqOcl3a1CUxRo+Rh0TTY0Fc2f4JN5tNK
nWWQ==
X-Forwarded-Encrypted: i=1; AL+hErHVogxcZp0rCwZOfBADP5kJWr1NQOlzSBZ6FZSZ0Eqb/BfKQNNyH91xGThtXOukIbQI9NGL28k=@vger.kernel.org
X-Gm-Message-State: APuU4Z+mBgTig2Vrx3s7Bfhm/udBJFeBONdXOwzyFgShwn2tVpvm3yVs
o9IbIFX6vylN5yMjxC91aNDe5aiCYuhO6SF3c14el/SWo0x87F7r7NCC
X-Gm-Gg: AZFdTZdP/cMxGaH0mcIix22zEYkDYKi62AbaNrQ3v5LxfB5b+HxlaKMuZGzD68gH0ct
VjYbQFDqGHLu40Zd8QwIZGtwqwo+bi/vU91+dgN/RvyBiv7XY6G3cY+5+K3DKsV26I1D5/qp2m0
V02mslynPn8DKpE0jT8wBDRK9MsOUDFnS1x02rVBj+fzxGLm5B+1CnCMe8Mgu6RyOGPaDNhvI3s
drN424i+pLYA1LLscpcs31Hy1e3sLe6iO3+EFSE/u0legxOuGK4gYEq3W9iElgB8Eu5FGobNGy7
Fswlv8M/711hIcWy62YMnmdsQ/hxw4MQypXVVkRaFJOcohE+LRzkH3Gj3JpyRMFxtJ4Z9J2+Kya
B9o4yItaI0djQaXvjrd51z/bHgxVzKW5Dolj/lcOr6hDKGYxhOfmzUBUBpc7DzsV6ZYnAl88AK2
EyLccSPBsEwAJaOSwB/QO5QrJMQ3ODTSMQg3il5EMEgeDk0bT/ZIWtz6REY36n07Z4EG1YlsvUD
j95KXHGRbki9iJ2dHsZflWFTvA4sIqnOnVpfvFVZ+950rTMu08K+ZaK9lhzmIUW82TEjloFA6EB
AYK1P4s0MIhNU1Z9BAbg7KKJsDmJ9AyUB6ASxOT+ykoucHA4OUtJAf0LLLjgonAHDrEg
X-Received: by 2002:a05:6870:1764:b0:475:e2e9:4f54 with SMTP id 586e51a60fabf-4bc8540032dmr9275570fac.34.1795436020855;
Mon, 23 Nov 2026 04:13:40 -0800 (PST)
X-Received: from localhost.localdomain ([14.116.239.36])
by smtp.gmail.com with ESMTPSA id 586e51a60fabf-4bc55895b9csm10063431fac.0.2026.11.23.04.13.33
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Mon, 23 Nov 2026 04:13:39 -0800 (PST)
X-Cc: horms@kernel.org,
netdev@vger.kernel.org,
Henry Martin <bsdhenrymartin@gmail.com>,
stable@vger.kernel.org,
Daniel Machon <daniel.machon@microchip.com>
X-Mailer: git-send-email 2.43.7
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