From: Liu Chao <liuc63@xiaopeng.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Andrew Morton <akpm@linux-foundation.org>
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
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 [thread overview]
Message-ID: <20261105072147.3383565-1-liuc63@xiaopeng.com> (raw)
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
next reply other threads:[~2026-11-05 7:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 7:21 Liu Chao [this message]
2026-11-05 7:21 ` [PATCH v3 1/2] lib/net_utils: allow mac_pton() to take a custom delimiter Liu Chao
2026-11-05 7:21 ` [PATCH v3 2/2] usb: gadget: u_ether: fix out-of-bounds read in get_ether_addr Liu Chao
2026-11-05 12:13 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261105072147.3383565-1-liuc63@xiaopeng.com \
--to=liuc63@xiaopeng.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@intel.com \
--cc=davem@davemloft.net \
--cc=dbrownell@users.sourceforge.net \
--cc=edumazet@kernel.org \
--cc=fangxy@xiaopeng.com \
--cc=gregkh@linuxfoundation.org \
--cc=horms@kernel.org \
--cc=khtsai@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rdunlap@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®