mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Antonio Pastor <antonio.pastor@gmail.com>
To: netdev@vger.kernel.org, edumazet@google.com
Cc: antonio.pastor@gmail.com, pabeni@redhat.com, horms@kernel.org,
	kuba@kernel.org, "David S. Miller" <davem@davemloft.net>,
	linux-kernel@vger.kernel.org
Subject: [PATCH net v2] net: 802: LLC+SNAP OID:PID lookup on start of skb data
Date: Thu,  2 Jan 2025 20:23:00 -0500	[thread overview]
Message-ID: <20250103012303.746521-1-antonio.pastor@gmail.com> (raw)
In-Reply-To: <CANn89iKkrZySKRidPLFa=KsM6h6OeO2rgW6t5WNY9OWfJazu8g@mail.gmail.com>

802.2+LLC+SNAP frames received by napi_complete_done() with GRO and DSA
have skb->transport_header set two bytes short, or pointing 2 bytes
before network_header & skb->data. This was an issue as snap_rcv()
expected offset to point to SNAP header (OID:PID), causing packet to
be dropped.

A fix at llc_fixup_skb() (a024e377efed) resets transport_header for any
LLC consumers that may care about it, and stops SNAP packets from being
dropped, but doesn't fix the problem which is that LLC and SNAP should
not use transport_header offset.

Ths patch eliminates the use of transport_header offset for SNAP lookup
of OID:PID so that SNAP does not rely on the offset at all.
The offset is reset after pull for any SNAP packet consumers that may
(but shouldn't) use it.

Fixes: fda55eca5a33 ("net: introduce skb_transport_header_was_set()")
Signed-off-by: Antonio Pastor <antonio.pastor@gmail.com>
---
 net/802/psnap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/802/psnap.c b/net/802/psnap.c
index fca9d454905f..389df460c8c4 100644
--- a/net/802/psnap.c
+++ b/net/802/psnap.c
@@ -55,11 +55,11 @@ static int snap_rcv(struct sk_buff *skb, struct net_device *dev,
 		goto drop;
 
 	rcu_read_lock();
-	proto = find_snap_client(skb_transport_header(skb));
+	proto = find_snap_client(skb->data);
 	if (proto) {
 		/* Pass the frame on. */
-		skb->transport_header += 5;
 		skb_pull_rcsum(skb, 5);
+		skb_reset_transport_header(skb);
 		rc = proto->rcvfunc(skb, dev, &snap_packet_type, orig_dev);
 	}
 	rcu_read_unlock();
-- 
2.43.0


  parent reply	other threads:[~2025-01-03  1:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20241220142020.1131017-1-antonio.pastor@gmail.com>
2024-12-23 13:39 ` [PATCH net v2] net: llc: explicitly set skb->transport_header Antonio Pastor
2024-12-23 13:54   ` Eric Dumazet
     [not found]     ` <c8145fd0-df13-4c6a-8678-fbf9547cc112@gmail.com>
2024-12-23 18:18       ` Eric Dumazet
2024-12-25  1:35         ` Antonio Pastor
2024-12-28  2:12           ` [PATCH net] net: 802: reset skb->transport_header Antonio Pastor
2024-12-30  8:26             ` Eric Dumazet
2025-01-03  0:18               ` Antonio Pastor
2025-01-03  1:23               ` Antonio Pastor [this message]
2025-01-03  8:46                 ` [PATCH net v2] net: 802: LLC+SNAP OID:PID lookup on start of skb data Eric Dumazet
2025-01-04 16:20                 ` patchwork-bot+netdevbpf
2024-12-25  1:07     ` [PATCH net v3] net: llc: reset skb->transport_header Antonio Pastor
2024-12-26  9:38       ` Eric Dumazet
2024-12-27 19:30       ` patchwork-bot+netdevbpf

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=20250103012303.746521-1-antonio.pastor@gmail.com \
    --to=antonio.pastor@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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®