Article View: linux.kernel.netdev
Article #11524[PATCH v3 0/2] usb: gadget: u_ether: fix out-of-bounds read in get_ether_addr
From: Liu Chao
Date: Thu, 05 Nov 2026 07:21
Date: Thu, 05 Nov 2026 07:21
53 lines
10783 bytes
10783 bytes
Rework of
[PATCH v2] usb: gadget: u_ether: fix out-of-bounds read in get_ether_addr
https://lore.kernel.org/all/20261104025058.2650911-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 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. commit 2b3d942c4878 ("usb ethernet gadget:
split out network core") only copies the loop into the new
u_ether.c; in drivers/usb/gadget/ether.c it is already present in
commit 1da177e4c3f4 ("Linux-2.6.12-rc2"), so the defect predates the
git history and there is no mainline commit to point at
- 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:
<20261105072147.3383565-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-357125-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-357125-linux-kernel-netdev=dewy.ru
From: liuc63@xiaopeng.com (Liu Chao)
Newsgroups: linux.kernel.netdev
Subject: [PATCH v3 0/2] usb: gadget: u_ether: fix out-of-bounds read in get_ether_addr
Date: Thu, 5 Nov 2026 15:21:45 +0800
Organization: Usenet Network
Message-ID: <20261105072147.3383565-1-liuc63@xiaopeng.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="3582907"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:wLEdnPslwqibjlJyTtFKSdXl9rg= sha256:f3apa2DyVnUC+65RsF1Cs+LjIIzFHXE8aYq3pd+wlk4=
sha1:Y+Wqdg3DcmcXE32i/GUXdQB3b/Y= sha256:FdASWPUIGrW80H6R3RKcYf7RH0eTa+XPJOn9A+F/8Ss=
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 C1035112EB6; Thu, 5 Nov 2026 10:25:26 +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 Jo9sqwG4AoJS;
Thu, 5 Nov 2026 10:25:22 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-357125-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 6B73E112EA8; Thu, 5 Nov 2026 10:25:14 +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 BC43F2B853; Thu, 5 Nov 2026 07:22:05 +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=1793863324;
b=C6V2CQDyUUNKsF/mcY3pNXIoIp9vUugGJ3eec1sKhsP+vUpdBTzD5zOvjUXHlSUZIrzn
u3SE1zqYCcA6an7JqGD3q+C9kRAGhMJ8KE8u9BMbljzaUuAbHLL/BgFw5YZQIvhdpmHZv
yL5ITq2qXFy+puuamazO231THWAvO1gCgqfArSctv+fSHfz8I6CSGWdSL4THC8eexgtxN
AZ5dZRc+CBEv2OxVBqzV3R3DZ9oQD8mh5l1jWgBjfPmJMl88OuRdMTuw8KVVtaQsU2OSw
TpkN+tgDDEdbi50MJ4YWR5eZrre8jPfKIKdjKtaWi8kcS8KkjQMsmsXDF4RQkp6ai8g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793863324;
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=LTLu+I3aouMczWmmEHyuqhA7vSrJ6hSqAiX0k5uFl2s=;
b=OLL//zjTqsRcWnMv08z98IRO73ivOe/yj5Cr8Yv7kTQI89nWlDeQoUhIt06ArvXmZopC
bSIFLEP2znFrVM720+6K7t7Zb44wzxcmBFfZsoGWKuDADWMm7KPCyOf7Tf+XeCjddeKyL
JcjxLkfzuvLeSmH1UwVlfJ+iClMjdGlOG/51TWzxEknAoukIGHcIcQrw6WKZ9zFAZoz+T
k52w8+z5aU0pXeItIDhfVdJmqFWFGTFdSF0s/xL+pE5cmPNRbHSnvaDE+O82Y9p5zYO23
ntMFeJQLEOgMLfHYY3uwTS2vTi6PCfHjRo0cZq7OyibZtQpWs9Nlfe8soDZcl29x2ww==
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=GOumxeBq;
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 882AD606D80B;
Thu, 5 Nov 2026 07:22:04 +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=GOumxeBq
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.28.51
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1793863323;
b=IeY/THHRfk6y5yja8Yd5IIG9SLMXSL5AUTnUwll8BWrosGZoy1EyxQLpFPVc0cc2MIeG
Wgt5K6uBoDB5P0GEIp2gOAPbOSjzCNsCCCpS3RntX8oJV4S8qQX9uaadvDerl9ejUU7DG
KTWL9HR1QbN2MEroCd+4ByHK+iz5LM9ADdyR5MHv0a7bBhEWYUlsF2lTo9n0VDCMVKie1
ZIjVWV29gnPOr4E1HcPbvEWMMM9+qaWmPyad+8IKixIOfkyrQci8y6+A7jAp0I3FW979p
hLoPO5X/zRnCDEfupgZHNC/n/WYDm7ilyKQ5MLgvn3P7qKAtjPTyDBI6JmIdjlP7Vjw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793863323;
h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:From:To:Cc:
Subject:Date:Message-ID:X-Mailer:MIME-Version:
Content-Transfer-Encoding;
bh=LTLu+I3aouMczWmmEHyuqhA7vSrJ6hSqAiX0k5uFl2s=;
b=E4q/EGS5TDz48GU7+L88DFPNJP70x2KXC13m6zHUz2QJVKJykWlfALrDHNzK5bpuyJbg
tCcwkegHtGJrV8CpfLZXmzAZOq7Mi8iLphmtaszRqmyp69s6rfh8F3mktFYiBhm6fnW+M
s4hi7Sugc7eFiVxfLC0NCUqY0j54ar/ycx4xrQKA2zB2VxteqPidAH58tAQbThMw+KonN
6aUt8I97NUv7TvPV5EAqaRxGuYeDNXBSV7rXgFa9mHxHNjfn4AJzfPj9dS5I91r6XGwUz
XDck6A6EmUJnV9TOXGyH3Zd3idMFxQmgJkS/q5Shu6JUSGdbeaxP/TXNRtiOEmzSILg==
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=GOumxeBq;
arc=none smtp.remote-ip=115.124.28.51
X-Received: from out28-51.mail.aliyun.com (out28-51.mail.aliyun.com [115.124.28.51])
(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 5FF82606A326;
Thu, 5 Nov 2026 07:21:59 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5FF82606A326
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=1793863310; h=From:To:Subject:Date:Message-ID:MIME-Version;
bh=LTLu+I3aouMczWmmEHyuqhA7vSrJ6hSqAiX0k5uFl2s=;
b=GOumxeBqizZ9HhsXA63AIsGt8fqsbRV+mNQfsAoVcwCQQ0JcS3sauyxRk2a8UXu7ZDTimuG9RA0SZmgSbmHW+yDCo7oRcp34DwwZSbevqYEyjxvcd9+UHXv9BNK4eF1QZmqkvWOZFVQnbDR4dbADI8A/6Im0/k54XHYSaO7yDbg=
X-Alimail-AntiSpam: AC=CONTINUE;BC=0.09765808|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_regular_dialog|0.00260988-0.000500615-0.99689;FP=14482862507635871152|0|0|0|0|-1|-1|-1;HT=maildocker-contentspam033037006180;MF=liuc63@xiaopeng.com;NM=1;PH=DS;RN=15;RT=15;SR=0;TI=SMTPD_---.jxPfor8_1793863307;
X-Received: from localhost(mailfrom:liuc63@xiaopeng.com fp:SMTPD_---.jxPfor8_1793863307 cluster:ay29)
by smtp.aliyun-inc.com;
Thu, 05 Nov 2026 15:21:48 +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