mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Jakub Kicinski <kuba@kernel.org>
Cc: mkl@pengutronix.de, Prithvi <activprithvi@gmail.com>,
	andrii@kernel.org, linux-can@vger.kernel.org,
	linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com,
	netdev@vger.kernel.org
Subject: Re: [bpf, xdp] headroom - was: Re: Question about to KMSAN: uninit-value in can_receive
Date: Wed, 7 Jan 2026 16:34:13 +0100	[thread overview]
Message-ID: <8b55ae26-daba-4b2e-a10b-4be367fb42d0@hartkopp.net> (raw)
In-Reply-To: <20260106162306.0649424c@kernel.org>

Hello Jakub,

On 07.01.26 01:23, Jakub Kicinski wrote:
> On Tue, 6 Jan 2026 13:04:41 +0100 Oliver Hartkopp wrote:
>> When such skb is echo'ed back after successful transmission via
>> netif_rx() this leads to skb->skb_iif = skb->dev->ifindex;
>>
>> To prevent a loopback the CAN frame must not be sent back to the
>> originating interface - even when it has been routed to different CAN
>> interfaces in the meantime (which always overwrites skb_iif).
>>
>> Therefore we need to maintain the "real original" incoming interface.
> 
> Alternatively perhaps for this particular use case you could use
> something like metadata_dst to mark the frame as forwarded / annotate
> with the originating ifindex?

I looked into it and the way how skb_dst is shared in the union behind 
cb[] does not look very promising for skbs that wander up and down in 
the network layer. And it is pretty complex to just store a single 
interface index integer value.

While looking into _sk_redir to see how the _skb_refdst union is used, 
I've seen that the _sk_redir function was removed from struct tcp_skb_cb 
(commit e3526bb92a208).

Today we use skb->cb only for passing (address) information from the 
network layer to the socket layer and user space. But the space in cb[] 
could also hold the content we currently store in the problematic skb 
headroom.

Would using skb->cb be a good approach for CAN skbs (that do not have 
any of the Ethernet/TCP/IP requirements/features) or will there still be 
networking code (besides CAN drivers and CAN network layer) that writes 
into cb[] when passing the CAN skb up and down in the stack?

/**
  * struct can_skb_cb - private data inside CAN skb->cb
  * cb[] is 64 bit aligned which is also recommended for struct sockaddr_can
  * @magic:	to check if someone wrote to our CAN skb->cb space
  * @flags:	extra flags for CAN_RAW and CAN_BCM sockets
  * @can_addr:	socket address information to userspace
  * @can_iif:	ifindex of the first interface the CAN frame appeared on
  * @skbcnt:	atomic counter to have an unique id together with skb pointer
  * @frame_len:	bql length cache of CAN frame in data link layer
  */
struct can_skb_cb {
	u32 magic;
	u32 flags;
	struct sockaddr_can can_addr;
	int can_iif;
	int skbcnt;
	unsigned int frame_len;
};

If not: We also don't have vlans nor inner[protocol|headers] in CAN 
where we might store the 4 byte can_iif integer ...

Many thanks and best regards,
Oliver

  reply	other threads:[~2026-01-07 15:34 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-05 13:36 [syzbot] [can?] KMSAN: uninit-value in can_receive (3) syzbot
2025-11-17 17:30 ` Question about to KMSAN: uninit-value in can_receive Prithvi Tambewagh
2025-11-29 17:04   ` Oliver Hartkopp
2025-11-30 12:04     ` Feedback provided on question about " Prithvi Tambewagh
2025-11-30 12:44     ` Question about to " Oliver Hartkopp
2025-11-30 17:29       ` Prithvi Tambewagh
2025-11-30 19:09         ` Oliver Hartkopp
2025-12-07 18:45           ` Prithvi
2025-12-20 17:33           ` Prithvi
2025-12-21 18:29             ` [bpf, xdp] headroom - was: " Oliver Hartkopp
2025-12-21 19:06               ` Marc Kleine-Budde
2025-12-21 19:42                 ` Oliver Hartkopp
2026-01-02 15:36               ` Prithvi
2026-01-02 20:04                 ` Jakub Kicinski
2026-01-03 12:20                   ` Oliver Hartkopp
2026-01-04 15:42                     ` Jakub Kicinski
2026-01-05 13:47                       ` Oliver Hartkopp
2026-01-05 23:26                         ` Jakub Kicinski
2026-01-06 12:04                           ` Oliver Hartkopp
2026-01-07  0:23                             ` Jakub Kicinski
2026-01-07 15:34                               ` Oliver Hartkopp [this message]
2026-01-07 19:10                                 ` Oliver Hartkopp
2026-01-08 15:17                                 ` Jakub Kicinski
2026-01-08 16:27                                   ` Oliver Hartkopp
2026-01-05 21:30                     ` Andrii Nakryiko
2026-01-05 22:11                   ` Daniel Borkmann
2025-11-28 17:48 ` Feedback on question about " Prithvi Tambewagh

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=8b55ae26-daba-4b2e-a10b-4be367fb42d0@hartkopp.net \
    --to=socketcan@hartkopp.net \
    --cc=activprithvi@gmail.com \
    --cc=andrii@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=syzkaller-bugs@googlegroups.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

all inboxes | Powered by JetHome®