From: Vincent Mailhol <mailhol@kernel.org>
To: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: "Oliver Hartkopp" <socketcan@hartkopp.net>,
"Stéphane Grosjean" <stephane.grosjean@hms-networks.com>,
"Robert Nawrath" <mbro1689@gmail.com>,
"Minh Le" <minh.le.aj@renesas.com>,
"Duy Nguyen" <duy.nguyen.rh@renesas.com>,
linux-can@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/9] can: dev: can_dev_dropped_skb: drop CAN FD skbs if FD is off
Date: Sat, 18 Oct 2025 00:30:45 +0900 [thread overview]
Message-ID: <00e3d382-99e7-4b64-955a-cceffe9e471f@kernel.org> (raw)
In-Reply-To: <20251017-bizarre-enchanted-quokka-f3c704-mkl@pengutronix.de>
On 17/10/2025 at 22:27, Marc Kleine-Budde wrote:
> On 17.10.2025 10:28:38, Marc Kleine-Budde wrote:
>> On 13.10.2025 20:01:23, Vincent Mailhol wrote:
>>> Currently, the CAN FD skb validation logic is based on the MTU: the
>>> interface is deemed FD capable if and only if its MTU is greater or
>>> equal to CANFD_MTU.
>>>
>>> This logic is showing its limit with the introduction of CAN XL. For
>>> example, consider the two scenarios below:
>>>
>>> 1. An interface configured with CAN FD on and CAN XL on
>>>
>>> 2. An interface configured with CAN FD off and CAN XL on
>>>
>>> In those two scenarios, the interfaces would have the same MTU:
>>>
>>> CANXL_MTU
>>>
>>> making it impossible to differentiate which one has CAN FD turned on
>>> and which one has it off.
>>>
>>> Because of the limitation, the only non-UAPI-breaking workaround is to
>>> do the check at the device level using the can_priv->ctrlmode flags.
>>> Unfortunately, the virtual interfaces (vcan, vxcan), which do not have
>>> a can_priv, are left behind.
>>>
>>> Add a check on the CAN_CTRLMODE_FD flag in can_dev_dropped_skb() and
>>> drop FD frames whenever the feature is turned off.
>>>
>>> Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
>>
>> What about merging both can_dev_dropped_skb() an
>> can_dropped_invalid_skb() in the skb.c, so that there is no stub in the
>> header file anymore.
>
> Ouch! Don't do this. We still need can_dropped_invalid_skb() for virtual
> interfaces. See commit ae64438be192 ("can: dev: fix skb drop check").
Exactly!
> But then I'm asking: Why is there the difference between virtual and
> non-virtual interface in the first place? Can we get rid of it?
The fact is that:
- We need a function for the physical interfaces to check the
CAN_CTRLMODE_LISTENONLY, i.e. with an access to struct can_priv.
- We need a similar function but which work for the virtual
interfaces which do not have a can_priv member.
So unless we do a major code refactor so that the virtual interfaces,
I do not see how we could get rid of it.
>> Someone (i.e. me) used can_dropped_invalid_skb() in a driver, that means
>> the check for CAN_CTRLMODE_LISTENONLY is missing :/ (I'll send a fix).
At least, this does not seem like a security breach like it was the
case for the missing net_device_ops->ndo_change_mtu().
> These drivers need this fix:
>
> | drivers/net/can/bxcan.c:845: if (can_dropped_invalid_skb(ndev, skb))
> | drivers/net/can/esd/esdacc.c:257: if (can_dropped_invalid_skb(netdev, skb))
> | drivers/net/can/rockchip/rockchip_canfd-tx.c:75: if (can_dropped_invalid_skb(ndev, skb))
Yeah, I think that this is a pitfall, but at the same time, I do not
see how to get rid of this can_dev_dropped_skb() and
can_dropped_invalid_skb() pair. The best I can think of it to be
careful on this problem doing the code review now that we are aware
about it.
Yours sincerely,
Vincent Mailhol
next prev parent reply other threads:[~2025-10-17 15:30 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-13 11:01 [PATCH 0/9] can: netlink: add CAN XL Vincent Mailhol
2025-10-13 11:01 ` [PATCH 1/9] can: dev: can_dev_dropped_skb: drop CAN FD skbs if FD is off Vincent Mailhol
2025-10-17 8:28 ` Marc Kleine-Budde
2025-10-17 13:27 ` Marc Kleine-Budde
2025-10-17 15:30 ` Vincent Mailhol [this message]
2025-10-17 15:34 ` Marc Kleine-Budde
2025-10-13 11:01 ` [PATCH 2/9] can: netlink: add CAN_CTRLMODE_RESTRICTED Vincent Mailhol
2025-10-13 11:01 ` [PATCH 3/9] can: netlink: add initial CAN XL support Vincent Mailhol
2025-10-13 11:01 ` [PATCH 4/9] can: netlink: add CAN_CTRLMODE_XL_TMS flag Vincent Mailhol
2025-10-13 11:01 ` [PATCH 5/9] can: netlink: add CAN_CTRLMODE_XL_ERR_SIGNAL Vincent Mailhol
2025-10-13 11:01 ` [PATCH 6/9] can: bittiming: add PWM parameters Vincent Mailhol
2025-10-13 11:01 ` [PATCH 7/9] can: bittiming: add PWM validation Vincent Mailhol
2025-10-13 11:01 ` [PATCH 8/9] can: calc_bittiming: add PWM calculation Vincent Mailhol
2025-10-13 21:21 ` kernel test robot
2025-10-14 2:05 ` Vincent Mailhol
2025-10-14 2:19 ` Vincent Mailhol
2025-10-14 2:32 ` Vincent Mailhol
2025-10-13 11:01 ` [PATCH 9/9] can: netlink: add PWM netlink interface Vincent Mailhol
2025-10-13 11:44 ` [PATCH 0/9] can: netlink: add CAN XL Vincent Mailhol
2025-10-17 13:53 ` Marc Kleine-Budde
2025-10-17 15:40 ` Vincent Mailhol
2025-10-17 16:02 ` Marc Kleine-Budde
2025-10-17 16:20 ` Vincent Mailhol
2025-10-17 16:34 ` Marc Kleine-Budde
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=00e3d382-99e7-4b64-955a-cceffe9e471f@kernel.org \
--to=mailhol@kernel.org \
--cc=duy.nguyen.rh@renesas.com \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mbro1689@gmail.com \
--cc=minh.le.aj@renesas.com \
--cc=mkl@pengutronix.de \
--cc=socketcan@hartkopp.net \
--cc=stephane.grosjean@hms-networks.com \
/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;
as well as URLs for NNTP newsgroup(s).