Linux CAN drivers development
 help / color / mirror / Atom feed
* [PATCH 0/2] can: j1939: tighten TP receive-path checks
@ 2026-09-07 14:56 Liu Chao
  2026-09-07 14:56 ` [PATCH 1/2] can: j1939: reject TP RTS with wrong packet count Liu Chao
  2026-09-07 14:56 ` [PATCH 2/2] can: j1939: check received packet count before completing session Liu Chao
  0 siblings, 2 replies; 5+ messages in thread
From: Liu Chao @ 2026-09-07 14:56 UTC (permalink / raw)
  To: Robin van der Gracht, Oleksij Rempel, Oliver Hartkopp,
	Marc Kleine-Budde
  Cc: kernel, linux-can, netdev, linux-kernel, stable, Liu Chao

j1939_xtp_rx_rts_session_new() allocates the receive buffer based on
the message size from RTS dat[1..2], but then overwrites pkt.total
with dat[3] even when they disagree.  A sender can set dat[3] smaller
so the session completes after fewer packets than the buffer was sized
for, delivering a short message to userspace.  With dat[3]=0 the
session just hangs until timeout.

eb96c58907922546 ("can: j1939: transport: j1939_session_fresh_new():
initialize receive buffer") addressed a related symptom by zeroing the
receive buffer, but the root cause -- blindly trusting dat[3] -- is
still there.

Patch 1 aborts the session when dat[3] doesn't match.
Patch 2 adds a pkt.rx check in the EOMA handler for unicast receive
sessions (BAM completes via the final flag in j1939_xtp_rx_dat_one,
not through EOMA).

Liu Chao (2):
  can: j1939: reject TP RTS with wrong packet count
  can: j1939: check received packet count before completing session

 net/can/j1939/transport.c | 37 ++++++++++++++++++++++++++++++-------
 1 file changed, 30 insertions(+), 7 deletions(-)

-- 
2.50.1


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

end of thread, other threads:[~2026-09-09 18:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-07 14:56 [PATCH 0/2] can: j1939: tighten TP receive-path checks Liu Chao
2026-09-07 14:56 ` [PATCH 1/2] can: j1939: reject TP RTS with wrong packet count Liu Chao
2026-09-07 14:56 ` [PATCH 2/2] can: j1939: check received packet count before completing session Liu Chao
2026-09-08 14:57   ` sashiko-bot
2026-09-09 18:05     ` Liu Chao

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