🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #11961

[PATCH v4 0/2] usb: gadget: u_ether: fix out-of-bounds read in get_ether_addr

#11961
From: Liu Chao
Date: Fri, 06 Nov 2026 03:06
62 lines
11138 bytes
Rework of

  [PATCH v3] usb: gadget: u_ether: fix out-of-bounds read in get_ether_addr
  https://lore.kernel.org/all/20261105072147.3383565-1-liuc63@xiaopeng.com/

following Andy's review: 1/2 prepares a parse_mac_pton() helper in
lib/net_utils.c, 2/2 uses it in get_ether_addr().

The two patches belong to different trees: 1/2 touches lib/ and should go
via netdev or -mm, 2/2 is for the USB tree.  2/2 depends on 1/2, so it
can only be applied once 1/2 has reached Linus' tree.

Changes since v3:
  - no code change at all, the tree is byte identical to what Andy
    reviewed, only the log of 2/2 changed
  - 1/2: unchanged
  - 2/2: pick up Andy's Reviewed-by
  - 2/2: name 331a2d82bcaf ("[PATCH] USB: ethernet/rndis gadget address
    params") from v2.6.7 as the commit that introduced the loop, and
    record that it only resolves in the history.git tree, which is why
    the series carries no Fixes tag
  - 2/2: record that the Cisco notation and irregular groupings are
    historical and rarely met these days, and that the commit introducing
    the loop never documented accepting them

Changes since v2:
  - 1/2: pick up Andy's Reviewed-by, no code change
  - 2/2: keep the separator-less notation "aabbccddeeff" working by
    falling back to hex2bin() when parse_mac_pton() does not match, as
    suggested by Andy
  - 2/2: drop the Fixes tag, the loop predates the git history
  - 2/2: spell out in the log which notations stop being accepted

Changes since v1:
  - rework the fix on top of parse_mac_pton() as suggested by Andy
    instead of open coding the bounds checks in get_ether_addr()
  - add the KASAN report and the malformed address example that v1 was
    missing, both collected on a KASAN build by loading g_ether with a
    short and with a non-hex dev_addr
  - select GENERIC_NET_UTILS for USB_U_ETHER
  - drop Cc: stable: 2/2 calls parse_mac_pton(), which 1/2 introduces,
    so it cannot be backported to any stable tree on its own

One user visible effect remains: the Cisco notation "aabb.ccdd.eeff" and
irregular groupings such as "123456:789abc" are no longer parsed and now
fall back to a random address.  Details are in the log of 2/2.

Liu Chao (2):
  lib/net_utils: allow mac_pton() to take a custom delimiter
  usb: gadget: u_ether: fix out-of-bounds read in get_ether_addr

 drivers/usb/gadget/Kconfig            |  1 +
 drivers/usb/gadget/function/u_ether.c | 18 ++++++++----------
 include/linux/hex.h                   |  7 ++++++-
 lib/net_utils.c                       | 17 ++++++++++++++---
 4 files changed, 29 insertions(+), 14 deletions(-)


base-commit: a5ebb76233b79db01e82e061173cb73c6d2b5c6b
-- 
2.50.1
Technical Details
Message-ID: <20261106030605.576584-1-liuc63@xiaopeng.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-357706-linux-kernel-netdev=dewy.ru

Show 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-357706-linux-kernel-netdev=dewy.ru
From: liuc63@xiaopeng.com (Liu Chao)
Newsgroups: linux.kernel.netdev
Subject: [PATCH v4 0/2] usb: gadget: u_ether: fix out-of-bounds read in get_ether_addr
Date: Fri,  6 Nov 2026 11:06:03 +0800
Organization: Usenet Network
Message-ID: <20261106030605.576584-1-liuc63@xiaopeng.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3783138"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:IkcVtdYtpgBFxIDpZOiLttKvMCM= sha256:Vpo8+yDoOPmJTpjUYo0qbeCH1DLpTJPKEWG6knY1rHo=
	sha1:njg2uLdj9KCv4l+swxI2dMtebiQ= sha256:DwgWZ4jeeApK79pV7ChiY0/5aUSvXeW63YYHcBRUBac=
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 9CCDE113108; Fri,  6 Nov 2026 06:10:36 +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, UNPARSEABLE_RELAY=0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=xiaopeng.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 NHd2maHeDSIZ;
	Fri,  6 Nov 2026 06:10:33 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-357706-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=xiaopeng.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id CB80F1130FA; Fri,  6 Nov 2026 06:10:24 +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 42B1B31C9C; Fri,  6 Nov 2026 03:06:29 +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=1793934389;
	b=C/VDF/HLaIfvQq6ctiTXcKdCQviEA++KUVa05dRtG4veFsxwnC119lxf/pCT3yY5Nbxi
	 xnkd0Rzln8WNu/EXUjFU1X2jZDUrtJjX567cN+xKWA3DH0yx5z7eY6d0VJNC7Pc/Y60wW
	 h3c/2Qtq2qlpmgEqnlb2FNNv+VFVYVB+qrw+dodeWrq6ygaobgedgrMR6DZTUTIuRYTJp
	 u2GIqKHxrIfj7+twfpYTzCf0VWGojQxtDu4lHXXKA1FrSbakggLnJCSmqLN9wMmiwsE3x
	 0vHT1Ak6KP1lvH6oCzWHVcs0apLeUrEofcp27Pi4wn6PFDdjPazDoJU7sV46bR5UG1A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793934389;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:
	 X-Alimail-AntiSpam: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=SFN7QdsDLQ4jCa9vD0JR+UWCPjLFqpbGwK2CZE9LN7Q=;
	b=MlS3g87oWqPmkHv5P9RTVmqyqvuwdwEJ9mLEpNbMOZdZhEAvKUw8Yp6b6nRe7qDiecNF
	 YXbl+LGGuaObNqJpqdWpf/o7uhBF+aOyPo1A/JERkwtLkeJCue0enEsGijHNbYqkY0+r8
	 ugfxIg6xRU2nTPgf2YzTDwk9qL4YaRWzd5GAthJ4axouk5aoHQxLVEHn1beyu68C++N5p
	 He69bdslujKEi1FR1giPgMyUj75nh/SIRkwa3pYuddXHm6NpB3s7T56DDhFWq6tUY04FY
	 9STAndBV9Z2IDk2ojFFkTU/IeGkJhrwXdoWt6gdGX4lY2JH52pG5kHyHysIjj3bO6lg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=xiaopeng.com header.i=@xiaopeng.com header.a=rsa-sha256 header.s=default header.b=FgImZkCd;
	dmarc=none header.from=xiaopeng.com;
	spf=pass smtp.mailfrom=xiaopeng.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 F229E606A33C;
	Fri,  6 Nov 2026 03:06:28 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=xiaopeng.com header.i=@xiaopeng.com header.a=rsa-sha256 header.s=default header.b=FgImZkCd
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.28.125
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793934378;
	b=Rcs+OxrD0s1IIjwnuFEeA/saFREx192sm1g31J0jJ934X/MqJZoTVlCog7P0kjviAVVi
	 q4Fa2p5/d6L1YHW2kS1uR+Oym8zCQITH9mSFQcc2Hpphjc8FOQuxLrtlaTBifgLiPrMR2
	 SsSZo4roXK57MYBLnOaoLGpHZ9qvPcmLO55AvmmB0wgzvbNq4TW0JS/MH2BmjTfrEFzL0
	 RvjP/eT/tNQQyiJlWKh4121lokl/6kOyHFeq/D9cvLhRbuYnbGWAXSpwwfITFnWCgc6AM
	 jb6FZRTFVu+ll+9KdNNYoA3YlVN/imJNw+Mtj372gi2+9Y1uzOzkcxrZlSdJXkQpWKQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793934378;
	h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:From:To:Cc:
	 Subject:Date:Message-ID:X-Mailer:MIME-Version:
	 Content-Transfer-Encoding;
	bh=SFN7QdsDLQ4jCa9vD0JR+UWCPjLFqpbGwK2CZE9LN7Q=;
	b=CjBjyCaTcRmQsmbJQFcy4LsIqEOUk3MHd+l6/s1fesW9E2VO6RA4zOaex2Hs6cBQzbki
	 jIINPtTTPu3KTTycL2Mhj7wJVp5NMAZAT6AhKjY9ysfLtBzQ/JfcGMX5z6Gy3XpDlaSPX
	 4jTLXIatDbah/4wQ0pznX5aRfsaB8LkeTvp85m5iJQnWqfeQs4mf/Q96Ju0sg/Rtk3Tme
	 1JnD3zOYmcYPKc/Z9XvmirlvguNwE8kFuYlm5eOmmi9eeUyKQnQpI/7Lh7MtzyttYhiXl
	 AfHAJ5+S7qSwTxVS4sUEF4gVCGWgSaft5+iLe95BM7PQhomA+wwdh/MbZo9CcpE33sw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=none header.from=xiaopeng.com;
	spf=pass smtp.mailfrom=xiaopeng.com;
	dkim=pass header.d=xiaopeng.com header.i=@xiaopeng.com header.a=rsa-sha256 header.s=default header.b=FgImZkCd;
	arc=none smtp.remote-ip=115.124.28.125
X-Received: from out28-125.mail.aliyun.com (out28-125.mail.aliyun.com [115.124.28.125])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id B76E2606A32E;
	Fri,  6 Nov 2026 03:06:15 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B76E2606A32E
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=xiaopeng.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xiaopeng.com
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=xiaopeng.com; s=default;
	t=1793934368; h=From:To:Subject:Date:Message-ID:MIME-Version;
	bh=SFN7QdsDLQ4jCa9vD0JR+UWCPjLFqpbGwK2CZE9LN7Q=;
	b=FgImZkCd6E7D4QLeUEq7KLPuUJMtdg2oTdtirex5JYmt7O5pR9VzBhtadavbFL4uUSX4yVgECOwFhSt/NbfDD8RbKq9ayHzh2z4ALosHjL6A970AKfXn3aiyNxkV8YpQWAUMyuUlbMX8Z0DE2kTiYdRJ5KI461AByBlZl2LOK9o=
X-Alimail-AntiSpam: AC=CONTINUE;BC=0.07902923|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_regular_dialog|0.00260988-0.000500615-0.99689;FP=14554920093083864496|0|0|0|0|-1|-1|-1;HT=maildocker-contentspam033037034138;MF=liuc63@xiaopeng.com;NM=1;PH=DS;RN=15;RT=15;SR=0;TI=SMTPD_---.jxsfG3j_1793934365;
X-Received: from localhost(mailfrom:liuc63@xiaopeng.com fp:SMTPD_---.jxsfG3j_1793934365 cluster:ay29)
          by smtp.aliyun-inc.com;
          Fri, 06 Nov 2026 11:06:06 +0800
X-Cc: Andy Shevchenko <andriy.shevchenko@intel.com>,
	"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>,
	khtsai@google.com,
	fangxy@xiaopeng.com,
	Randy Dunlap <rdunlap@infradead.org>,
	dbrownell@users.sourceforge.net,
	linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org
X-Mailer: git-send-email 2.50.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