All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net v3 0/2] net: usb: lan78xx: do not use uninitialized data after short reads
@ 2026-10-18  6:24 Wei Jie Law
  2026-10-18  6:24 ` [PATCH net v3 1/2] net: usb: lan78xx: do not update statistics after a failed read Wei Jie Law
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Wei Jie Law @ 2026-10-18  6:24 UTC (permalink / raw)
  To: Thangaraj Samynathan, UNGLinuxDriver, Andrew Lunn,
	David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: Woojung Huh, netdev, linux-usb, linux-kernel, Wei Jie Law

lan78xx_read_reg() and lan78xx_read_stats() accept a control transfer
that returns fewer bytes than requested and then use the uninitialized
rest of their kmalloc()ed buffers. A device that sends short replies can
get stale heap contents used as the MAC address of the interface, and makes
ethtool -S report them to unprivileged users, including kernel text and
direct map pointers.

Patch 2 makes both helpers fail on short reads. Patch 1 comes first so
that a failing statistics read does not report uninitialized stack data
instead.

The bugs need a malicious or emulated USB device, which
Documentation/process/threat-model.rst treats as a regular bug rather
than a vulnerability, so they are posted publicly.

Testing: the series builds without warnings (W=1) on net and passes
checkpatch --strict. It applies unchanged to v6.12.105, where it was
tested with a LAN7800 emulated by raw-gadget + dummy_hcd, booted with
init_on_alloc=0:

- Zero-length statistics replies. Before: 40 to 88 of the 235 ethtool -S
  counters are non-zero, including usb_api_blocking_completion() and
  direct map pointers. After: every read fails with -EIO and all
  counters stay zero.

- 100 byte statistics replies. Before: 110 of the 235 counters are
  non-zero. With patch 1 only: 29 are, so the stale tail of the buffer
  still gets through. With both patches: the read fails with -EIO and
  all counters stay zero.

- Zero-length RX_ADDRL/RX_ADDRH replies. Before: the MAC address
  differs on every probe, is programmed into the MAC filter and is
  used as the address of the interface. After: the
  probe fails with -EIO.

Both bugs were found, and the patches written, with LLM assistance,
hence the Assisted-by tags.

Changes in v3:
- add the missing Signed-off-by; no other changes
Changes in v2 (review by Sashiko):
- 2/2: the commit message now says that with patch 1 only a partial
  statistics reply (1 to 187 bytes) still leaks, and that patch 2 depends on
  patch 1; the MAC address paragraph no longer claims a write-back to
  RX_ADDRL/RX_ADDRH, which happens only for an invalid address. The cover
  letter gains a partial-reply test. No code change.
- v2: https://lore.kernel.org/all/20261018061734.19488-1-law.wei.jie@gt.tech.gov.sg/
- v1: https://lore.kernel.org/all/20261014025602.26334-1-law.wei.jie@gt.tech.gov.sg/

Wei Jie Law (2):
  net: usb: lan78xx: do not update statistics after a failed read
  net: usb: lan78xx: reject short register and statistics reads

 drivers/net/usb/lan78xx.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)


base-commit: 7ec48f396a1d89532c0537bc38b408b8c31ee37f
-- 
2.43.0


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

end of thread, other threads:[~2026-10-18 16:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-18  6:24 [PATCH net v3 0/2] net: usb: lan78xx: do not use uninitialized data after short reads Wei Jie Law
2026-10-18  6:24 ` [PATCH net v3 1/2] net: usb: lan78xx: do not update statistics after a failed read Wei Jie Law
2026-10-18  6:26   ` sashiko-bot
2026-10-18  6:24 ` [PATCH net v3 2/2] net: usb: lan78xx: reject short register and statistics reads Wei Jie Law
2026-10-18  6:26   ` sashiko-bot
2026-10-18 16:12 ` [PATCH net v3 0/2] net: usb: lan78xx: do not use uninitialized data after short reads Andrew Lunn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.