From: Vincent Mailhol <mailhol@kernel.org>
To: Oliver Hartkopp <socketcan@hartkopp.net>,
Marc Kleine-Budde <mkl@pengutronix.de>
Cc: linux-can@vger.kernel.org
Subject: Re: [RFC PATCH] can: dev: can_dev_dropped_skb: drop CAN FD skbs if FD is off
Date: Mon, 8 Sep 2025 13:07:52 +0900 [thread overview]
Message-ID: <5edbe004-767f-4a41-9454-f4bbf8f5b590@kernel.org> (raw)
In-Reply-To: <49e0970f-1a10-438f-b9ae-afcc75edaccd@hartkopp.net>
On 08/09/2025 at 04:03, Oliver Hartkopp wrote:
> Hi Vincent,
>
> can_dev_dropped_skb() is not what you are looking for.
>
> Whether a CAN frame fits to the CAN device is checked in raw_check_txframe() here:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/net/can/
> raw.c#n884
>
> Or do I miss anything?
My point is not if it fits or not. Of course, if CAN XL is activated, CAN FD
frames would fit.
My point is that activating CAN XL should not imply that CAN FD is also
activated. Having CAN FD off and CAN XL on is a valid configuration.
Let me take an example, imagine that I configure my device with CAN FD off and
CAN XL on, for example:
ip link set can0 up type can bitrate 500000 \
fd off \
xl on xbitrate 10000000 tms on
Where is the check that, with this configuration, the device is not CAN FD
capable and that the FD frames should be dropped? When I try this under my dummy
driver, the FD frames pass the raw_check_txframe() check, reach the driver's
xmit function and pass the can_dev_dropped_skb() checks. And that is the problem.
So, yes, the frame "fits" in above configuration and no buffer overflows nor any
other security problems occurred. But CAN FD is off so the frame should have
been discarded at some point.
The same issue goes for probing. How do you detect if an interface is CAN FD
capable? By checking that its MTU is at least CANFD_MTU? For example like this
in cangen?
https://github.com/linux-can/can-utils/blob/master/cangen.c#L802-L805
If I do this check, it would wrongly detect that my interface is CAN FD capable
when in fact, it is turned off in the configuration. So, under my previous
example, cangen is also fooled into believing that it can send CAN FD frames
when in reality the option is turned off.
So, these are my point:
- how do you configure a vcan so that CAN FD is off and CAN XL is on?
- when CAN FD is off and CAN XL is on, how do you drop CAN FD frames in the
kernel TX path ?
- in the userland, how do you probe that an interface is CAN FD capable or
not?
Does this clarify the problem?
Yours sincerely,
Vincent Mailhol
next prev parent reply other threads:[~2025-09-08 4:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-07 8:05 [RFC PATCH] can: dev: can_dev_dropped_skb: drop CAN FD skbs if FD is off Vincent Mailhol
2025-09-07 19:03 ` Oliver Hartkopp
2025-09-08 4:07 ` Vincent Mailhol [this message]
2025-09-08 9:00 ` Oliver Hartkopp
2025-09-08 13:30 ` Vincent Mailhol
2025-09-08 14:59 ` Oliver Hartkopp
2025-09-08 16:31 ` Vincent Mailhol
2025-09-08 16:55 ` Oliver Hartkopp
2025-09-08 17:42 ` Vincent Mailhol
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=5edbe004-767f-4a41-9454-f4bbf8f5b590@kernel.org \
--to=mailhol@kernel.org \
--cc=linux-can@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