mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Quchaosheng <quchaosheng000406@163.com>
To: Kaixuan Li <kaixuanli0131@gmail.com>
Cc: Oliver Hartkopp <socketcan@hartkopp.net>,
	Marc Kleine-Budde <mkl@pengutronix.de>,
	linux-can@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] can: isotp: check the frame type, not just the length
Date: Thu, 22 Oct 2026 15:57:37 +0800	[thread overview]
Message-ID: <179265585720.316860.4020901999690965834@163.com> (raw)
In-Reply-To: <20260920035626.2581040-1-kaixuanli0131@gmail.com>

Re-checked this against a 7.3-rc7 tree before it went in; recording what was
measured.

The field offsets in the message are right:

  sizeof(struct can_frame)    16    CAN_MTU
  sizeof(struct canfd_frame)  72    CANFD_MTU
  canxl_frame: data at 12, len at 6, flags at 4

canxl->len == 4 makes a 16-byte skb, which is CAN_MTU and passes
"skb->len != so->ll.mtu" on a Classic channel.  Cast to struct canfd_frame,
the byte at offset 4 is canxl->flags, and CANXL_XLF is 0x80 and mandatory,
so cf->len is 0xff in the run below.  The flow-control path uses that length
without bounding it, which is what check_pad() walks to 255 over.

Measured on v7.3-rc7 under QEMU/KVM on vcan with mtu 2060, two kernels from
one tree differing only in this hunk:

  A  a CAN XL frame with len 4 injected into a Classic socket with
     RX_PADDING | CHK_PAD_LEN | CHK_PAD_DATA:
       without the patch  recv() -> EBADMSG
       with the patch     no EBADMSG
  B  legitimate traffic and the padding check:
       CC ok-unpadded / ok-padded / wrong-padding    intact, intact, EBADMSG
       FD ok-unpadded / ok-padded / wrong-padding    intact, intact, EBADMSG
     identical on both kernels.

B matters because the guard sits in front of the code that reports bad
padding.  The wrong-padding cases still report EBADMSG on the patched
kernel, and the CAN FD channel is unaffected.

Reviewed-by: Quchaosheng <quchaosheng000406@163.com>


  parent reply	other threads:[~2026-10-22  7:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-19  0:01 [RFC PATCH] firmware_loader: fix use-after-free in fw_load_sysfs_fallback() Ian Bridges
2026-09-28  6:50 ` Quchaosheng
2026-09-17 12:37   ` [PATCH v2] can: restore skb header initialisations in init_can_skb() zjamg
2026-09-28  6:50     ` Quchaosheng
2026-09-20  3:56   ` [PATCH v2] can: isotp: check the frame type, not just the length Kaixuan Li
2026-09-20 18:13     ` Oliver Hartkopp
2026-09-28  6:50     ` Quchaosheng
2026-10-22  7:57     ` Quchaosheng [this message]
2026-10-09 14:19   ` [RFC PATCH] firmware_loader: fix use-after-free in fw_load_sysfs_fallback() Ian Bridges

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=179265585720.316860.4020901999690965834@163.com \
    --to=quchaosheng000406@163.com \
    --cc=kaixuanli0131@gmail.com \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=socketcan@hartkopp.net \
    /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®