Linux USB
 help / color / mirror / Atom feed
* [PATCH v7 0/2] usb: gadget: u_ether: fix out-of-bounds read in get_ether_addr
@ 2026-12-01  2:44 Liu Chao
  2026-12-01  2:44 ` [PATCH v7 1/2] lib/net_utils: allow mac_pton() to take a custom delimiter Liu Chao
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Liu Chao @ 2026-12-01  2:44 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Andrew Morton
  Cc: Andy Shevchenko, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, khtsai, fangxy, Randy Dunlap,
	dbrownell, linux-usb, linux-kernel, netdev

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-12-01  2:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01  2:44 [PATCH v7 0/2] usb: gadget: u_ether: fix out-of-bounds read in get_ether_addr Liu Chao
2026-12-01  2:44 ` [PATCH v7 1/2] lib/net_utils: allow mac_pton() to take a custom delimiter Liu Chao
2026-12-01  2:44 ` [PATCH v7 2/2] usb: gadget: u_ether: fix out-of-bounds read in get_ether_addr Liu Chao
2026-12-01  2:51 ` [PATCH v7 0/2] " sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox