Article View: linux.kernel.netdev
Article #20337Re: [PATCH net-next] net: zero hw address entries on allocation
From: Andrew Lunn
Date: Sun, 22 Nov 2026 04:10
Date: Sun, 22 Nov 2026 04:10
22 lines
9131 bytes
9131 bytes
On Sun, Nov 22, 2026 at 09:26:33AM +0900, Yuyang Huang wrote:
> __hw_addr_create() allocates struct netdev_hw_addr with kmalloc() and
> copies only addr_len bytes into ha->addr[MAX_ADDR_LEN], leaving the
> rest uninitialized.
>
> If dev->addr_len later grows while entries remain (e.g., adding a
> multicast address to a down TAP device with SIOCADDMULTI and then
> switching it to ARPHRD_TUNNEL6 via TUNSETLINK), readers using
> dev->addr_len such as /proc/net/dev_mcast and AF_PACKET
> RTM_GETMULTICAST expose the uninitialized trailing slab bytes, and
> __hw_addr_add_ex() reads them in memcmp().
>
> Switch __hw_addr_create() to kzalloc() so the unused tail of ha->addr
> is always zero.
>
> Link: https://lore.kernel.org/netdev/179012275175.2160803.16091441325063775173@kernel.org/
> Signed-off-by: Yuyang Huang <yuyanghuang@google.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
Technical Details
Message-ID:
<86c2de6e-0369-406f-8d8d-99bd8d538e5a@lunn.ch>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368575-linux-kernel-netdev=dewy.ruReferences:
<20261122002633.584362-1-yuyanghuang@google.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368575-linux-kernel-netdev=dewy.ru From: andrew@lunn.ch (Andrew Lunn) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next] net: zero hw address entries on allocation Date: Sun, 22 Nov 2026 05:10:28 +0100 Organization: Usenet Network Message-ID: <86c2de6e-0369-406f-8d8d-99bd8d538e5a@lunn.ch> References: <20261122002633.584362-1-yuyanghuang@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="3567964"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:X6jv/MX0rfBN8qeIyKrpSzDZHv0= sha256:U0SXXiIOw079WGeBy6CeRQer/FwDRCSytFPUcxLG+E8= sha1:tPiUth+bYa8RJqf/uxiiZWBL6bo= sha256:tOuOY52q53VU/cJ+b55LHP5qDw0kj5Zyip9m2lu0S4Q= Content-Disposition: inline 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 34FB5DFFA1; Sun, 22 Nov 2026 07:11:07 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.05 X-Spam-Status: No, score=-3.05 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, 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, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=lunn.ch 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 B7dvqnR4515B; Sun, 22 Nov 2026 07:10:59 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-368575-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=lunn.ch X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 36083125D42; Sun, 22 Nov 2026 07:10:47 +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 8040C2A503; Sun, 22 Nov 2026 04:10: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=1795320643; b=mPOp8EEoIkTe+Z0zA/n6w64s8Ay8n0t1sj4RtP/CZ95vDqQsD4lMvwXF28dsC1b06nm5 sQOqTj3ILAGOxcBW8avv1OqGgOw/H3X16oUhHf5dqf3PdW+3fSeBEe4XctYpuOqJ7Azj6 aMX2qnKeiNsig+UfdWqNMgd2sUigKRIdLc0dH3NIKCUQCsZGbRGcQCjYzO/XhYJkeQyBB ljOZwuCitL6w172jmR44lzqvNkPoe+PrBQvVplphYXjwcwXKmWbkcev1NdK33hU+x1pRJ 6+98mhAf3WHuSCqdLRQm0UldCRvqg7InVezjvoAs7NnzUnUVDYBBo9aLUparf2vGVKw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795320643; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:Date: From:To:Cc:Subject:Message-ID:References:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=F4mN48hur/hnwPKJx2MzvhdiyTLGTAwTU2udreX/VTk=; b=yuvfSkKAmvNvVLuTqJnk0UPTDnmNsGHDaMYaXH0m8osyP7NjEu5CkKz5gH5eDLWmmynp rj8q6XxFnzkHgu7TZijnrFsnoOcXej+6YDC0htpaYenuWct5a8BU3V6uk/L655Bi5POB7 FRl2h/KCvH2u8WHP0B4ZNJBNbay0aaKDIdS+gMCISQA5jXGhpJUx2GuUeJur2ZT4j1zSB 6y6G3cb2grqpTqFqxrAKVHDw0CA2F9Q2NdJjY7ZMENmZtG105TjvCi/1YJmg6I8xsA8Tj aZRJ5hl/gKQUyFTbDIr3xQ8ZDERZ192+BAXBn6JcLbpU+a6IT9NHSJsExtUTx5NP4xA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=lunn.ch header.i=@lunn.ch header.a=rsa-sha256 header.s=20171124 header.b=iZqrAFEe; dmarc=pass header.from=lunn.ch; spf=pass smtp.mailfrom=lunn.ch; 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 13A8E606A333; Sun, 22 Nov 2026 04:10:43 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.a=rsa-sha256 header.s=20171124 header.b=iZqrAFEe X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=156.67.10.101 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795320642; b=2+Hif0WcoqZQJYdlGXoG8tQayraMvEl7TvRFO439e0cD7phJxhATY7P0otfpsNfzwWnE 07UAJ7qOFUucpUemWGFz87VAj3XTksz5VhT9tksntjN1IGHwiTq1Ulu/YMtswlDjHt4df 0otBDK0DJ/ApUbHdKZbN5KHwF8o/ndV6xlrG3X9xoNLrKxH2UMjEh3HOVmatbdmqxP0Kc Pt5odSLkjC5UHi+3lWTLALKGx9haeBsRSJJkgLsBQYpLAqtepqkPr7nJUbukOI3ZHiWso ArSvPUqmVLhwdNOo8JS1l5BlEQaM1YmtHyKFzbhdqzRLbYJ+b6qpFw16tOJdOyEz7Hg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795320642; h=DMARC-Filter:DKIM-Signature:Received:Date:From:To:Cc:Subject: Message-ID:References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To; bh=F4mN48hur/hnwPKJx2MzvhdiyTLGTAwTU2udreX/VTk=; b=CruR6jtJjgvo+QjUO5yyi/uJmjhMli5k7C+atfeypBuC1Flzj6WvDZnFwkpQZd/2t91T h8EXo8VvaZT5cU+LGlBfSgPw5D7LnNmobCncaMoPUvL0+S/ybBi1kcfgwp1kvRaGZzsV7 WucRvkXONEQWCRkKTzbxNujKCuOxJvLy/UmnQ6Wee32T/zZGhlW3Mzb05Viyenqauv8dY kHO2N20ylk8DxQBG57o1BbQYoDkwsNEdCjSuYes1qNgRcJFtfuKH3mG6KKE05dK/Yv3dG 71+fd//yX9qyq4ix/GT8sZg/lWoCz1Hs1ViOd/A5mRedghs7IbhlOP6GKOJZ5Ww3dBQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=lunn.ch; spf=pass smtp.mailfrom=lunn.ch; dkim=pass header.d=lunn.ch header.i=@lunn.ch header.a=rsa-sha256 header.s=20171124 header.b=iZqrAFEe; arc=none smtp.remote-ip=156.67.10.101 X-Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B49B8606A320 for <netdev@vger.kernel.org>; Sun, 22 Nov 2026 04:10:41 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B49B8606A320 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lunn.ch X-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=F4mN48hur/hnwPKJx2MzvhdiyTLGTAwTU2udreX/VTk=; b=iZqrAFEe8ZXNnbk0OuKebsNc2K 0sdGSKW0ZMjPW97oR0gFhUPa8faTRvdUbXN2B3ESlMU+dX4Xo8AHBd436dztvvM0JTeTg7Z2KSv2t EU1SWStf5uATFGqmOYhGRhy1ZYBG+by1GeR8fDq4k2iNgzh8AdaonQi3XafR15VWVb4M=; X-Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from <andrew@lunn.ch>) id 1xUyuK-000Wpp-Ga; Sun, 22 Nov 2026 05:10:28 +0100 X-Cc: "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Nicolas Dichtel <nicolas.dichtel@6wind.com>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>, Stanislav Fomichev <sdf.kernel@gmail.com>, netdev@vger.kernel.org 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 X-In-Reply-To: <20261122002633.584362-1-yuyanghuang@google.com>