Netdev List
 help / color / mirror / Atom feed
* [PATCH net v2 0/2] net/ncsi: validate response packet and GMCMA lengths
@ 2026-12-02  3:36 Yuxiao Zhang
  2026-12-02  3:36 ` [PATCH net v2 1/2] net/ncsi: validate response packet lengths against skb Yuxiao Zhang
  2026-12-02  3:36 ` [PATCH net v2 2/2] net/ncsi: validate GMCMA address_count against packet length Yuxiao Zhang
  0 siblings, 2 replies; 4+ messages in thread
From: Yuxiao Zhang @ 2026-12-02  3:36 UTC (permalink / raw)
  To: Samuel Mendoza-Jonas, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Willem de Bruijn
  Cc: Paul Fertser, Simon Horman, Joel Stanley, Peter Delevoryas,
	Patrick Williams, netdev, Yuxiao Zhang

This 2-patch series fixes out-of-bounds reads in the NC-SI response RX
path:

1. Validate minimum response payload length and pull the common header,
   4-byte-aligned payload, and trailing checksum in ncsi_rcv_rsp() /
   ncsi_validate_rsp_pkt() (using size_t for ALIGN() to avoid 16-bit
   wraparound on 65533..65535), after unsharing the skb with
   skb_share_check() and replacing post-validation hdr->type uses with
   nrh->type.
2. Validate that the NC-SI payload length covers the fixed GMCMA header
   and all address_count * ETH_ALEN entries in ncsi_rsp_handler_gmcma().

Discovery & testing:
- Originally found via automated LLM-assisted code scanning and verified
  by manual code inspection. Not observed in production, but both
  out-of-bounds reads were reproduced at runtime on netdev/net with
  ARCH=um KUnit + KASAN (length=1538 in ncsi_validate_rsp_pkt() and
  length=8 / address_count=0xff in ncsi_rsp_handler_gmcma()).
- With both patches applied, all 9 KUnit + KASAN test cases pass (0
  KASAN reports), covering <16B headers, payload < 4, length=1538,
  length=65533..65535, GMCMA address_count=0xff, Ethernet-padded
  length=8 / address_count=3, GMCMA payload=4, odd-length checksums, and
  shared non-linear skbs. Also compile-tested on arm64 with W=1.

Changes in v2:
- Split into 2 patches in response to Sashiko AI review: move skb length
  validation and pskb_may_pull() up into ncsi_rcv_rsp() and
  ncsi_validate_rsp_pkt() (Patch 1/2) so short skbs with large
  hdr->length (e.g. 1538 or 0xffff) are rejected before *pchecksum and
  ncsi_calculate_checksum() read out of bounds.
- Simplify ncsi_rsp_handler_gmcma() (Patch 2/2) to check min_payload and
  address_count * ETH_ALEN against the already-validated payload length.
- Include discovery method and runtime ARCH=um KASAN reproduction
  details in the cover letter and commit messages per pw-bot feedback.
- Note: the pre-existing ncsi_rsp_handler_gp() bounds issue noted by
  Sashiko is separate and left for a follow-up patch.

Yuxiao Zhang (2):
  net/ncsi: validate response packet lengths against skb
  net/ncsi: validate GMCMA address_count against packet length

 net/ncsi/ncsi-rsp.c | 43 ++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 38 insertions(+), 5 deletions(-)


base-commit: 76fca30e8d34eb151fcf4f363b51c21b7e8c4709
-- 
2.56.1.839.g22a8290db9-goog


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

end of thread, other threads:[~2026-12-03  3:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02  3:36 [PATCH net v2 0/2] net/ncsi: validate response packet and GMCMA lengths Yuxiao Zhang
2026-12-02  3:36 ` [PATCH net v2 1/2] net/ncsi: validate response packet lengths against skb Yuxiao Zhang
2026-12-03  3:38   ` netdev-bot+sashiko
2026-12-02  3:36 ` [PATCH net v2 2/2] net/ncsi: validate GMCMA address_count against packet length Yuxiao Zhang

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