All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Amirkan via B4 Relay <devnull+markdamirkan.gmail.com@kernel.org>
To: Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
	 netdev@vger.kernel.org
Cc: Paolo Abeni <pabeni@redhat.com>,
	 "David S. Miller" <davem@davemloft.net>,
	linux-kernel@vger.kernel.org,  Jakub Kicinski <kuba@kernel.org>,
	Jon Rosen <jrosen@cisco.com>,  Simon Horman <horms@kernel.org>,
	Eric Dumazet <edumazet@google.com>
Subject: [PATCH net] net/packet: clear RX owner on VNET header error
Date: Sun, 13 Sep 2026 10:28:08 +0000	[thread overview]
Message-ID: <20260913-b4-send-packet-vnet-v1-1-5545ffb528ae@gmail.com> (raw)

From: Mark Amirkan <markdamirkan@gmail.com>

Commit 61fad6816fc1 ("net/packet: tpacket_rcv: avoid a producer race
condition") added rx_owner_map and made tpacket_rcv() claim a V1 or V2
ring slot before converting the virtio-net header.  If the conversion
fails, the drop path leaves the slot claimed.

With a one-frame TPACKET_V2 ring, an unsupported UDP GSO packet leaves
the only slot unavailable, so the ring also drops the next valid packet.

Clear the ownership bit on this error path.  TPACKET_V3 already clears
its block state here.

Fixes: 61fad6816fc1 ("net/packet: tpacket_rcv: avoid a producer race condition")
Cc: stable@vger.kernel.org
Assisted-by: Symbolic
Signed-off-by: Mark Amirkan <markdamirkan@gmail.com>
---
 net/packet/af_packet.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 76bde7906d..50cae32ae2 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2384,7 +2384,9 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
 	    virtio_net_hdr_from_skb(skb, h.raw + macoff -
 				    sizeof(struct virtio_net_hdr),
 				    vio_le(), true, 0)) {
-		if (po->tp_version == TPACKET_V3)
+		if (po->tp_version <= TPACKET_V2)
+			__clear_bit(slot_id, po->rx_ring.rx_owner_map);
+		else
 			prb_clear_blk_fill_status(&po->rx_ring);
 		goto drop_n_account;
 	}

---
base-commit: e6b6078ea1731b05b3b552497b3bce4bf8b014ae
change-id: 20260913-b4-send-packet-vnet-32b47964a7cf

Best regards,
--  
Mark Amirkan <markdamirkan@gmail.com>



WARNING: multiple messages have this Message-ID (diff)
From: Mark Amirkan <markdamirkan@gmail.com>
To: Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
	 netdev@vger.kernel.org
Cc: Paolo Abeni <pabeni@redhat.com>,
	 "David S. Miller" <davem@davemloft.net>,
	linux-kernel@vger.kernel.org,  Jakub Kicinski <kuba@kernel.org>,
	Jon Rosen <jrosen@cisco.com>,  Simon Horman <horms@kernel.org>,
	Eric Dumazet <edumazet@google.com>
Subject: [PATCH net] net/packet: clear RX owner on VNET header error
Date: Sun, 13 Sep 2026 10:28:08 +0000	[thread overview]
Message-ID: <20260913-b4-send-packet-vnet-v1-1-5545ffb528ae@gmail.com> (raw)

Commit 61fad6816fc1 ("net/packet: tpacket_rcv: avoid a producer race
condition") added rx_owner_map and made tpacket_rcv() claim a V1 or V2
ring slot before converting the virtio-net header.  If the conversion
fails, the drop path leaves the slot claimed.

With a one-frame TPACKET_V2 ring, an unsupported UDP GSO packet leaves
the only slot unavailable, so the ring also drops the next valid packet.

Clear the ownership bit on this error path.  TPACKET_V3 already clears
its block state here.

Fixes: 61fad6816fc1 ("net/packet: tpacket_rcv: avoid a producer race condition")
Cc: stable@vger.kernel.org
Assisted-by: Symbolic
Signed-off-by: Mark Amirkan <markdamirkan@gmail.com>
---
 net/packet/af_packet.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 76bde7906d..50cae32ae2 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2384,7 +2384,9 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
 	    virtio_net_hdr_from_skb(skb, h.raw + macoff -
 				    sizeof(struct virtio_net_hdr),
 				    vio_le(), true, 0)) {
-		if (po->tp_version == TPACKET_V3)
+		if (po->tp_version <= TPACKET_V2)
+			__clear_bit(slot_id, po->rx_ring.rx_owner_map);
+		else
 			prb_clear_blk_fill_status(&po->rx_ring);
 		goto drop_n_account;
 	}

---
base-commit: e6b6078ea1731b05b3b552497b3bce4bf8b014ae
change-id: 20260913-b4-send-packet-vnet-32b47964a7cf

Best regards,
--  
Mark Amirkan <markdamirkan@gmail.com>


             reply	other threads:[~2026-09-13 10:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-13 10:28 Mark Amirkan via B4 Relay [this message]
2026-09-13 10:28 ` [PATCH net] net/packet: clear RX owner on VNET header error Mark Amirkan
2026-09-13 22:38 ` Willem de Bruijn
2026-09-17  0:40 ` 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=20260913-b4-send-packet-vnet-v1-1-5545ffb528ae@gmail.com \
    --to=devnull+markdamirkan.gmail.com@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jrosen@cisco.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markdamirkan@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemdebruijn.kernel@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.