🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24910

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

#24910
From: Liu Chao
Date: Tue, 01 Dec 2026 02:44
79 lines
12119 bytes
Rework of

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

following Andy's reply on the v6 2/2 thread: 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 v6:
  - 2/2: as Andy suggested, consolidate the "rejected address, using random"
    warning into a single pr_warn inside get_ether_addr(), at the tail of
    the if (str) block; the two setters go back to their plain pre-v6 form
    (no warn at their call sites, no per-caller string, and the enclosing
    if (str) makes the NULL default path silent by construction)
  - 2/2: drop the unreferenced Link: trailer from the commit message
  - 1/2: unchanged

Changes since v5:
  - 2/2: correct the commit message so that the legacy module parameters
    are described via their real call path (gether_set_dev_addr() and
    gether_set_host_addr()); add a warning on a rejected caller-supplied
    address; amend the five configfs ABI notes to say the raw notation
    matches at the beginning of the input, trailing characters are ignored,
    and the address must be unicast and not all-zero

Changes since v4:
  - no driver code change; only documentation and the commit messages
  - 1/2: reword the parse_mac_pton() kernel-doc to say at least
    MAC_ADDR_STR_LEN characters, only the first MAC_ADDR_STR_LEN checked
  - 2/2: describe the configfs behaviour, name all five functions, restore
    a Fixes: tag for 1da177e4c3f4 ("Linux-2.6.12-rc2") keeping the real
    introducing commit in prose, and say "minimum length"

Changes since v3:
  - no code change, only the log of 2/2 changed; name 331a2d82bcaf from
    v2.6.7 as the commit that introduced the loop; pick up the Reviewed-by

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.  A
configfs store then fails with -EINVAL and keeps the previous value, while
the legacy module parameters keep the random address set up earlier and,
with this version, log a single warning naming the rejected address.

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       |  9 ++++++++-
 .../ABI/testing/configfs-usb-gadget-eem       |  9 +++++++++
 .../ABI/testing/configfs-usb-gadget-ncm       |  8 ++++++++
 .../ABI/testing/configfs-usb-gadget-rndis     |  9 +++++++++
 .../ABI/testing/configfs-usb-gadget-subset    |  9 +++++++++
 drivers/usb/gadget/Kconfig                    |  1 +
 drivers/usb/gadget/function/u_ether.c         | 20 +++++++++----------
 include/linux/hex.h                           |  7 ++++++-
 lib/net_utils.c                               | 19 +++++++++++++++---
 9 files changed, 76 insertions(+), 15 deletions(-)


base-commit: 24a19b953e2a3d0ea5a8c4951a0ab8f32720c907
-- 
2.50.1
Technical Details
Message-ID: <20261201024415.3340593-1-liuc63@xiaopeng.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder2.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374636-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder2.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374636-linux-kernel-netdev=dewy.ru
From: liuc63@xiaopeng.com (Liu Chao)
Newsgroups: linux.kernel.netdev
Subject: [PATCH v7 0/2] usb: gadget: u_ether: fix out-of-bounds read in get_ether_addr
Date: Tue,  1 Dec 2026 10:44:13 +0800
Organization: Usenet Network
Message-ID: <20261201024415.3340593-1-liuc63@xiaopeng.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network; logging-data="1593573"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:VdnCbW22IOtYfvjM5TVoxaeeajk= sha256:GpX8Avlzw5jKiW2Emx0HarhddGAuzqYIJayuXnqh+5M= sha1:DbTkVuqlzhs+9tqTsFgTFz1HJJU= sha256:30TeN21HXktxbEfjWJwkCFuL8bbC0FosqX/UC80NAX4=
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 E6237117203; Tue,  1 Dec 2026 05:44:45 +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, 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, URIBL_BLOCKED=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 tC-zaJqwPUeL; Tue,  1 Dec 2026 05:44:42 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374636-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 97F9A117165; Tue,  1 Dec 2026 05:44:33 +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 606F12A0AC; Tue,  1 Dec 2026 02:44: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=1796093068; b=YR7jQ0fhMr8JTKas4tUfPWw5iAJrsdW2JxlIHDY8GDoM/K1YBgfwqya2bAIDPV/ywlnh kMqmTUuLR9CJLQcVzukw+AUNzhbK0sLqQ11xTNCK5LLROuvkj+k0uI3ebP9b5krqEkzd1 GyhecAYME0BWANSnJlnO6NxtKzRb86P6reFAwcs90af3tx0cKBL9uTHiOpgELU5xd7ogY ouuJEP6NKGhrMHYGBQ2nFtudHSlb6q+VksS2SmRWhWvWPOb1etJPNAtp7Wt53b5t+f/Jz Ej1aBdrZQTjinyQJFPWSaO5wWHDdr9qD4TsOlYXse+3t0/ojeOtaDUTHda7NcqSay9Q==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796093068; 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=DzrItx6NoSF/1LoIiVNbWf1qXSzbXRN3Elf0jBwBTN8=; b=zLk7KJ0bUd9JT3pDyqF9xL2uWGl89YCdyT4gz/IvVQLeVrSA6wN8nWgzC0DSsvEW09lJ v5LpM6eTBOAcyGmf75ILvwFC+Xex/l/hMG93zoJo4QL4qLUEq0TgfoViecJKLpnvK+RXx hpCZ4hImgm2SywE95BDRew9oOergQAMolBM3XsAKcv2qzvhh5cHxTVr91vUzhbIiKO6Fp ADx2CsYsUZuO/ktQk1B93Q4u3HBh3nfAEifQ8F6peMIMsbqs7SszLB3M8odipfXJh/zsp Cg5JFcYbq0gHrwt9H/9/1liOa8TLi9OipUul4ep5Zluo/1n+hrqQ31x821GFQvGOh/Q==
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=PkVmzPc2; 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 C0F83606A338; Tue,  1 Dec 2026 02:44:28 +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=PkVmzPc2
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.28.76
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796093068; b=NBZOb7VsJhzRj3CeXX1z682EaAe04mj0C7IokFUcLSupAYDWSgIAwnDPdu40iQqOygpR WKtLX7FuUDn48ihUx6l1lhCJsvEMxsIcYgfv+ZJrvFdrwH2UCnA3uqlQ2X3iEXnvH/BKR yiEjRfMpZdn/n8QoZTn/m7TaHtgMiOQjUhdEpivOdukKiP4XYy8rgpF2cBb9OeWKJI78Q Xp3OcxIr1LsJY09rHb95LEzqZfN5ELWXsWtcgSm5dlcfUuEgRMZzSu0c2nUPl45ybv/eT BVo8nJQNT9ady7aAmS1tTqjqt9uzcBK6Y87rbXiVcRh6Ly1h4MkD5HL9S6dAbXcMxeg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796093068; h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:From:To:Cc: Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=DzrItx6NoSF/1LoIiVNbWf1qXSzbXRN3Elf0jBwBTN8=; b=D765+tCZK20BCdlQPCTXVZi/cMUMGIO15S3gfYpxL3LyCCexBD0w9VO7N0vZUKnuR6eM /ycjd16/KTLASTiliHDHGdSsHwIFUaa7h6XsK7nO6k8qLqC1fjm4rVG9VIDHAyDAo1TcJ T84KKrkf7ekJ6N4nzHvfuPXRw8M6DY9H23dOsz9txl1Zjamv9RHNrgbREaRa47XtVb/mA Jdm17lR9LSN+R9kN8e4zvVSDtK8ww2ysfikT8VAbiRBq/t5yY5O5LTyfFxhYGVQQbq97t b8Pn+0c+/LPtvEziVrBlGtsyc94YBWFaUbOefC+jJvL2eI482SptjlLfzzheRgu3UHQ==
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=PkVmzPc2; arc=none smtp.remote-ip=115.124.28.76
X-Received: from out28-76.mail.aliyun.com (out28-76.mail.aliyun.com [115.124.28.76]) (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 C4ECB606A320; Tue,  1 Dec 2026 02:44:26 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C4ECB606A320
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=1796093058; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=DzrItx6NoSF/1LoIiVNbWf1qXSzbXRN3Elf0jBwBTN8=; b=PkVmzPc29mZeRewOHIl7dsAvlUY6KlchofbXRN3DnbbbiD5p2yt63gyDK4ybHA9GJTkCQjp4Hs65KXobuokNfBFO92YirVnNb6sO6lIrW4S75ox95rJXFMrYCiuzRexymWgI24O5AxKzLtUz4FzS5NerMKlJVLHts/j+8wZ4hdQ=
X-Alimail-AntiSpam: AC=CONTINUE;BC=0.07562523|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_alarm|0.0202665-0.000761907-0.978972;FP=14699035143787875824|0|0|0|0|-1|-1|-1;HT=maildocker-contentspam033045005058;MF=liuc63@xiaopeng.com;NM=1;PH=DS;RN=15;RT=15;SR=0;TI=SMTPD_---.kDtpeY0_1796093055;
X-Received: from localhost(mailfrom:liuc63@xiaopeng.com fp:SMTPD_---.kDtpeY0_1796093055 cluster:ay29) by smtp.aliyun-inc.com; Tue, 01 Dec 2026 10:44:17 +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