From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Oliver Hartkopp <socketcan@hartkopp.net>
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 15:55:22 +0200 [thread overview]
Message-ID: <20220511135522.2qvhtokb4j5qvr3j@pengutronix.de> (raw)
In-Reply-To: <6f541d66-f52e-13e0-bfe9-91918af11503@hartkopp.net>
[-- Attachment #1: Type: text/plain, Size: 1679 bytes --]
On 11.05.2022 15:24:00, Oliver Hartkopp wrote:
> > Another use where skb->sk breaks is sending CAN frames with SO_TXTIME
> > with the sched_etf.
> >
> > I have a patched version of cangen that uses SO_TXTIME. It attaches a
> > time to transmit to a CAN frame when sending it. If you send 10 frames,
> > each 100ms after the other and then exit the program, the first CAN
> > frames show up as TX'ed while the others (after closing the socket) show
> > up as RX'ed CAN frames in candump.
>
> Hm, this could be an argument for the origin flag.
>
> But I'm more scared about your described behaviour. What happens if
> the socket is still open?
SO_TXTIME makes an existing race window really, really, really wide.
The race window is between sendmsg() returning to user space and
can_put_echo_skb() -> can_create_echo_skb() -> can_skb_set_owner(). In
can_skb_set_owner() a reference to the socket is taken, if the socket is
not closed:
| https://elixir.bootlin.com/linux/v5.17.6/source/include/linux/can/skb.h#L75
If the socket closes _after_ sendmsg(), but _before_ the driver calls
can_put_echo_skb() the CAN frame will have no socket reference and show
up as RX'ed.
> There obviously must be some instance removing the sk reference, right??
No. That's all fine. We fixes that in:
| https://lore.kernel.org/all/20210226092456.27126-1-o.rempel@pengutronix.de/
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2022-05-11 13:55 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 [this message]
2022-05-11 13:24 ` Marc Kleine-Budde
2022-05-11 14:36 ` Marc Kleine-Budde
2022-05-11 14:50 ` Oliver Hartkopp
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=20220511135522.2qvhtokb4j5qvr3j@pengutronix.de \
--to=mkl@pengutronix.de \
--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=netdev@vger.kernel.org \
--cc=o.rempel@pengutronix.de \
--cc=socketcan@hartkopp.net \
--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).