From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: Oleksij Rempel <o.rempel@pengutronix.de>,
Wolfgang Grandegger <wg@grandegger.com>,
Devid Antonio Filoni <devid.filoni@egluetechnologies.com>,
kernel@pengutronix.de, linux-can@vger.kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
David Jander <david@protonic.nl>
Subject: Re: [PATCH 1/1] can: skb: add and set local_origin flag
Date: Wed, 11 May 2022 16:50:06 +0200 [thread overview]
Message-ID: <002d234f-a7d6-7b1a-72f4-157d7a283446@hartkopp.net> (raw)
In-Reply-To: <20220511143620.kphwgp2vhjyoecs5@pengutronix.de>
On 5/11/22 16:36, Marc Kleine-Budde wrote:
> On 11.05.2022 15:24:21, Marc Kleine-Budde wrote:
>> On 11.05.2022 14:38:32, Oliver Hartkopp wrote:
>>> IMO this patch does not work as intended.
>>>
>>> You probably need to revisit every place where can_skb_reserve() is used,
>>> e.g. in raw_sendmsg().
>>
>> And the loopback for devices that don't support IFF_ECHO:
>>
>> | https://elixir.bootlin.com/linux/latest/source/net/can/af_can.c#L257
>
> BTW: There is a bug with interfaces that don't support IFF_ECHO.
>
> Assume an invalid CAN frame is passed to can_send() on an interface that
> doesn't support IFF_ECHO. The above mentioned code does happily generate
> an echo frame and it's send, even if the driver drops it, due to
> can_dropped_invalid_skb(dev, skb).
>
> The echoed back CAN frame is treated in raw_rcv() as if the headroom is valid:
>
> | https://elixir.bootlin.com/linux/v5.17.6/source/net/can/raw.c#L138
>
> But as far as I can see the can_skb_headroom_valid() check never has
> been done. What about this patch?
>
> index 1fb49d51b25d..fda4807ad165 100644
> --- a/net/can/af_can.c
> +++ b/net/can/af_can.c
> @@ -255,6 +255,9 @@ int can_send(struct sk_buff *skb, int loop)
> */
>
> if (!(skb->dev->flags & IFF_ECHO)) {
> + if (can_dropped_invalid_skb(dev, skb))
> + return -EINVAL;
> +
Good point!
But please check the rest of the code.
You need 'goto inval_skb;' instead of the return ;-)
Best,
Oliver
> /* If the interface is not capable to do loopback
> * itself, we do it here.
> */
>
> Marc
>
next prev parent reply other threads:[~2022-05-11 14:50 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-11 12:19 [PATCH 1/1] can: skb: add and set local_origin flag Oleksij Rempel
2022-05-11 12:38 ` Oliver Hartkopp
2022-05-11 12:53 ` Oleksij Rempel
2022-05-11 13:05 ` Marc Kleine-Budde
2022-05-11 13:24 ` Oliver Hartkopp
2022-05-11 13:55 ` Marc Kleine-Budde
2022-05-11 13:24 ` Marc Kleine-Budde
2022-05-11 14:36 ` Marc Kleine-Budde
2022-05-11 14:50 ` Oliver Hartkopp [this message]
2022-05-11 14:54 ` Marc Kleine-Budde
2022-05-11 14:57 ` Oliver Hartkopp
2022-05-12 6:23 ` Oliver Hartkopp
2022-05-12 7:58 ` Marc Kleine-Budde
2022-05-14 3:43 ` 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=002d234f-a7d6-7b1a-72f4-157d7a283446@hartkopp.net \
--to=socketcan@hartkopp.net \
--cc=david@protonic.nl \
--cc=devid.filoni@egluetechnologies.com \
--cc=kernel@pengutronix.de \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=netdev@vger.kernel.org \
--cc=o.rempel@pengutronix.de \
--cc=wg@grandegger.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).