🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #17713

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

#17713
From: Liu Chao
Date: Tue, 17 Nov 2026 09:00
76 lines
11909 bytes
Rework of

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

following Andy's review of v4: 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 v4:
  - no driver code change; the C diff of both patches is byte identical
    to v4, only documentation and the commit messages changed
  - 1/2: reword the parse_mac_pton() kernel-doc: @s must be at least
    MAC_ADDR_STR_LEN characters long, and only the first
    MAC_ADDR_STR_LEN characters are checked, the rest ignored
  - 2/2: describe the configfs behaviour change accurately: a rejected
    address makes the store fail with -EINVAL and keep its previous
    value, while only the legacy module parameters fall back to a random
    address
  - 2/2: name all five functions that reach the parser (ECM, EEM, NCM,
    RNDIS, subset) and document the accepted formats in their configfs
    ABI files
  - 2/2: restore a Fixes: tag pointing at 1da177e4c3f4
    ("Linux-2.6.12-rc2"), the start of the official git era, keeping the
    commit that really introduced the loop named in prose
  - 2/2: say "checks the minimum length" where v4 said "checks the
    length"

Changes since v3:
  - no code change at all, 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

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
  - 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
  - select GENERIC_NET_UTILS for USB_U_ETHER

One user visible effect remains: the Cisco notation "aabb.ccdd.eeff" and
irregular groupings such as "123456:789abc" are no longer parsed.  The
legacy module parameters then fall back to a random address and log a
warning, while a configfs store fails with -EINVAL and keeps the previous
value.  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

 .../ABI/testing/configfs-usb-gadget-ecm       |  7 ++++++-
 .../ABI/testing/configfs-usb-gadget-eem       |  7 +++++++
 .../ABI/testing/configfs-usb-gadget-ncm       |  6 ++++++
 .../ABI/testing/configfs-usb-gadget-rndis     |  7 +++++++
 .../ABI/testing/configfs-usb-gadget-subset    |  7 +++++++
 drivers/usb/gadget/Kconfig                    |  1 +
 drivers/usb/gadget/function/u_ether.c         | 18 ++++++++----------
 include/linux/hex.h                           |  7 ++++++-
 lib/net_utils.c                               | 19 ++++++++++++++++---
 9 files changed, 64 insertions(+), 15 deletions(-)


base-commit: a5ebb76233b79db01e82e061173cb73c6d2b5c6b
-- 
2.50.1
Technical Details
Message-ID: <20261117090110.3263592-1-liuc63@xiaopeng.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365074-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365074-linux-kernel-netdev=dewy.ru
From: liuc63@xiaopeng.com (Liu Chao)
Newsgroups: linux.kernel.netdev
Subject: [PATCH v5 0/2] usb: gadget: u_ether: fix out-of-bounds read in get_ether_addr
Date: Tue, 17 Nov 2026 17:00:33 +0800
Organization: Usenet Network
Message-ID: <20261117090110.3263592-1-liuc63@xiaopeng.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2285588"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:tUH/oGKiajQdc8zquXDXXLtL7Lk= sha256:kvY/J8AhM4Tvaf6in2PqD17/TaDkc5YACEvIMzD4Xy8=
	sha1:aTRRGK2ZEzji/vjI1D04gsMOxD8= sha256:2FHErbi0+cAVw8bM6Oh+W+t8vKzO+gnO4qpaDkcrino=
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 F2064114EAB; Tue, 17 Nov 2026 12:01:47 +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 z1MEhw7jNhzo;
	Tue, 17 Nov 2026 12:01:44 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-365074-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 F12A5114EA8; Tue, 17 Nov 2026 12:01:34 +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 53330389F3; Tue, 17 Nov 2026 09:01:24 +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=1794906084;
	b=tfGzTj64xN9FBZdKQhLN04R1r3msxkfxdtI+yOyZ6slAgwd9PzgGJ8Je3jHBpQYaZtra
	 8tL5BRW8xokFNNVhR5YoeVY6bDImiekckWsXOFzvxY5Fk6EUc4qYLhSDJWxuHkyTvASI9
	 wQTVdkQDjVWPHjUP9Yo8oBYeFqhUCruYWRKNCjqAZRZv54pC/Gl6w4p0X1KORLuPFzY5i
	 ujxooKnRT6oUQgTL7Pa5uCoUNASP3zLWsYVcOpXrLMBJBTxmuEb7tLPYC7xeLPR1uOaAS
	 ttf9Du5dlNdT8sAdYXzFgKtjY3TEXSu62g4v9JDOYEL5gxvwGVuP5SEu90mmFw7B6Fw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794906084;
	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=bPmJ4vo//kCU2q63ATfdNeDCC0CouN1mZHy++b3Tras=;
	b=WyGT0RNZGrSmJ8+AhTGLKrggcwDhPa/wL3EDw+REMQak3I+AegmZGGnhOeCnvULOzpJY
	 +E2MJqdFoWTQVFNYPsW63+3KnB1BNIGmtrcY7+3eTPwm88f23R847ZY2c20S/h/R7hHru
	 Z2iCjvOHhYYniY9xDoca9dFfj5X4ZAAX0x9U2K2ukgHHZOAEzqLj08BSXlUu2Va99QlBs
	 8pysco8TuxnawIDpUQHU1melKG9XluSUurS+fh7RXLabmsE7Rrq2QLfqzyiNH+8ZAJpYR
	 Pouy45EmGNyTsjxrolgGrl11qpwYWX7zgyBRC9mesyXW159MvG8nbCUV8xJzo8wp4KA==
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="tRbV/qoq";
	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 2A59C606A32A;
	Tue, 17 Nov 2026 09:01:24 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key) header.d=xiaopeng.com header.i=@xiaopeng.com header.a=rsa-sha256 header.s=default header.b=tRbV/qoq
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.28.170
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794906078;
	b=SI7cXZk1jI4wobvLbzNHy4XpFCc88utWe/1KRmADCpV940NCvqQJOeO4g02Pm5vV3fsQ
	 ppmrZWF2DTjzplt3aIG4Jm8cfB82K4t2s7UOuvLbCj7+4r77xkRC0YQ2Xz45p+0rr8DET
	 oaDDBprJ0yBdE0A1fHw2GDbYGXp1W7U31Mje7U2levg05MdJpvjEHwKJ1V2jOTj61rJwa
	 Fxky87/LURhyI6IqYZ2TzUB6AJePNB2mPvXPv1dSiFaiqKfpxnJb5DzeMTTixo8ruhtC/
	 WD9CYNFM+Qlc0rv/7AffBstudvvU0tiLd9w6scrsloI8PrMA31UwryH7uKNBJdSFj/w==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794906078;
	h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:From:To:Cc:
	 Subject:Date:Message-ID:X-Mailer:MIME-Version:
	 Content-Transfer-Encoding;
	bh=bPmJ4vo//kCU2q63ATfdNeDCC0CouN1mZHy++b3Tras=;
	b=YA8d1V2AVe2Ht6/E4xOUSwIwO2B8OAshG82zl7aHhSIRDcCmRYmqOK0zrmLVjH75hI9w
	 70oq3IJzlx/bX0UkbiH6OY2k99I8n98fsAnX1ePsfhaaTBhfxasF3mC6GWVGMiqXAN/gb
	 Ju6DK4pqJu4ybctpSHoHzUL03UQUjF/r7WaBfSWjSwBrEHgg+AsWG0hI1NKka8wa3xAo1
	 evZRxeuaTv2jOv26m+UTTuQMGGZfY14BWYYfY5HWX177TwzYIB/r3RKoY0HnqU8Ze5u0k
	 QRhVjyQOHDqfMMotvV1LlfFHt+LR0XX9VlvTfFLV46jApI7Ec02Yx+2/M/rlO8hNejQ==
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="tRbV/qoq";
	arc=none smtp.remote-ip=115.124.28.170
X-Received: from out28-170.mail.aliyun.com (out28-170.mail.aliyun.com [115.124.28.170])
	(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 8022B606A31C;
	Tue, 17 Nov 2026 09:01:16 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8022B606A31C
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=1794906074; h=From:To:Subject:Date:Message-ID:MIME-Version;
	bh=bPmJ4vo//kCU2q63ATfdNeDCC0CouN1mZHy++b3Tras=;
	b=tRbV/qoq7mnq+T5eI+6GcWDO+9vMZMMWFPzjWwFYlhMgyXe6y4J7x5jTHePvgLZci7YTsJnocwyBT2/d1lZocH0FhVs3AYeXVwtWou+rQNBcY5/P9xPWzqtLuEdRtnDc0VwFE4EXlucl4pZNojMb9FrqvJP8ccd2rgc0lrzCSPw=
X-Alimail-AntiSpam: AC=CONTINUE;BC=0.07614725|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_alarm|0.015819-0.000583497-0.983598;FP=16842748703785717168|0|0|0|0|-1|-1|-1;HT=maildocker-contentspam033045099153;MF=liuc63@xiaopeng.com;NM=1;PH=DS;RN=15;RT=15;SR=0;TI=SMTPD_---.k3m6Acz_1794906071;
X-Received: from localhost(mailfrom:liuc63@xiaopeng.com fp:SMTPD_---.k3m6Acz_1794906071 cluster:ay29)
          by smtp.aliyun-inc.com;
          Tue, 17 Nov 2026 17:01:12 +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