public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven@narfation.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: "Linus Lüssing" <linus.luessing@c0d3.blue>
Subject: Re: [PATCH v3 3/3] batman-adv: bcast: remove remaining skb-copy calls for broadcasts
Date: Sun, 30 May 2021 13:52:48 +0200	[thread overview]
Message-ID: <2507587.JJKAMBb5lu@sven-desktop> (raw)
In-Reply-To: <20210516223309.12596-3-linus.luessing@c0d3.blue>

[-- Attachment #1: Type: text/plain, Size: 1723 bytes --]

On Monday, 17 May 2021 00:33:09 CEST Linus Lüssing wrote:
[...]
> However
> after (queueing for) forwarding the packet in
> batadv_recv_bcast_packet()->batadv_forw_bcast_packet() a packet is
> additionally decapsulated and is sent up the stack through
> batadv_recv_bcast_packet()->batadv_interface_rx(). Which needs an
> unshared skb data for potential modifications from other protocols.
> To be able to use skb clones for (re)broadcasted batman-adv broadcast
> packets while still ensuring that interface_rx() has a freely writeable
> skb we use skb_cow() to avoid sharing skb data with the skb clones in

So you are talking here about netif_rx. But this doesn't seem to ensure that 
the data is "private" at all. It can even easily happen that there is a 
tcpdump listening at the same time on the interface which is "netif_rx"ing. In 
this case, both AF_PACKET and whatever is parsing the layer 3 stuff is 
receiving an skb_shared() skb.

In this case, the receiver of the skb must use skb_share_check to clone the 
skb - so we would end up with the same situation as you had before your 
skb_cow. And it must then for example use skb_cow_data to "gain" write access 
to the skb's data.


Take for example the bridge code. You can find the skb_share_check in 
br_handle_frame. Afterwards, it knows that it has a clone of the skb (but not 
necessarily a private copy of the actual data). If it needs to modify the data 
then it is copying the skb.

Another example is the IPv4 code. One of the first things it does is to check 
in ip_rcv_core for the shared skb. And if it needs to modify it (for example 
by forwarding it in ip_forward), it uses skb_cow directly.

Kind regards,
	Sven

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2021-05-30 11:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-16 22:33 [PATCH v3 1/3] batman-adv: bcast: queue per interface, if needed Linus Lüssing
2021-05-16 22:33 ` [PATCH v3 2/3] batman-adv: bcast: avoid skb-copy for (re)queued broadcasts Linus Lüssing
2021-05-16 22:33 ` [PATCH v3 3/3] batman-adv: bcast: remove remaining skb-copy calls for broadcasts Linus Lüssing
2021-05-30 11:52   ` Sven Eckelmann [this message]
2021-08-17 12:24   ` Sven Eckelmann

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=2507587.JJKAMBb5lu@sven-desktop \
    --to=sven@narfation.org \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=linus.luessing@c0d3.blue \
    /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