public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: netdev@vger.kernel.org
Cc: bpf@vger.kernel.org, magnus.karlsson@intel.com,
	stfomichev@gmail.com, kuba@kernel.org, pabeni@redhat.com,
	horms@kernel.org, larysa.zaremba@intel.com,
	aleksander.lobakin@intel.com, bjorn@kernel.org,
	Maciej Fijalkowski <maciej.fijalkowski@intel.com>,
	Stanislav Fomichev <sdf@fomichev.me>
Subject: [PATCH v4 net 01/11] xsk: tighten UMEM headroom validation to account for tailroom and min frame
Date: Thu, 26 Mar 2026 12:49:09 +0100	[thread overview]
Message-ID: <20260326114919.519456-2-maciej.fijalkowski@intel.com> (raw)
In-Reply-To: <20260326114919.519456-1-maciej.fijalkowski@intel.com>

The current headroom validation in xdp_umem_reg() could leave us with
insufficient space dedicated to even receive minimum-sized ethernet
frame. Furthermore if multi-buffer would come to play then
skb_shared_info stored at the end of XSK frame would be corrupted.

HW typically works with 128-aligned sizes so let us provide this value
as bare minimum.

Multi-buffer setting is known later in the configuration process so
besides accounting for 128 bytes, let us also take care of tailroom space
upfront.

Reviewed-by: Björn Töpel <bjorn@kernel.org>
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Fixes: 99e3a236dd43 ("xsk: Add missing check on user supplied headroom size")
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
---
 net/xdp/xdp_umem.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/xdp/xdp_umem.c b/net/xdp/xdp_umem.c
index 066ce07c506d..58da2f4f4397 100644
--- a/net/xdp/xdp_umem.c
+++ b/net/xdp/xdp_umem.c
@@ -203,7 +203,8 @@ static int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr)
 	if (!unaligned_chunks && chunks_rem)
 		return -EINVAL;
 
-	if (headroom >= chunk_size - XDP_PACKET_HEADROOM)
+	if (headroom > chunk_size - XDP_PACKET_HEADROOM -
+		       SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) - 128)
 		return -EINVAL;
 
 	if (mr->flags & XDP_UMEM_TX_METADATA_LEN) {
-- 
2.43.0


  reply	other threads:[~2026-03-26 11:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-26 11:49 [PATCH v4 net 00/11] xsk: tailroom reservation and MTU validation Maciej Fijalkowski
2026-03-26 11:49 ` Maciej Fijalkowski [this message]
2026-03-26 11:49 ` [PATCH v4 net 02/11] xsk: respect tailroom for ZC setups Maciej Fijalkowski
2026-03-26 11:49 ` [PATCH v4 net 03/11] xsk: fix XDP_UMEM_SG_FLAG issues Maciej Fijalkowski
2026-03-26 18:13   ` Björn Töpel
2026-03-26 11:49 ` [PATCH v4 net 04/11] xsk: validate MTU against usable frame size on bind Maciej Fijalkowski
2026-03-26 18:18   ` Björn Töpel
2026-03-26 11:49 ` [PATCH v4 net 05/11] selftests: bpf: introduce a common routine for reading procfs Maciej Fijalkowski
2026-03-26 11:49 ` [PATCH v4 net 06/11] selftests: bpf: fix pkt grow tests Maciej Fijalkowski
2026-03-26 11:49 ` [PATCH v4 net 07/11] selftests: bpf: have a separate variable for drop test Maciej Fijalkowski
2026-03-26 11:49 ` [PATCH v4 net 08/11] selftests: bpf: adjust rx_dropped xskxceiver's test to respect tailroom Maciej Fijalkowski
2026-03-26 11:49 ` [PATCH v4 net 09/11] idpf: remove xsk frame size check against alignment Maciej Fijalkowski
2026-03-26 11:49 ` [PATCH v4 net 10/11] igc: remove home-grown xsk's frame size validation Maciej Fijalkowski
2026-03-26 11:49 ` [PATCH v4 net 11/11] gve: " Maciej Fijalkowski
2026-03-26 23:04   ` Joshua Washington
2026-03-26 18:22 ` [PATCH v4 net 00/11] xsk: tailroom reservation and MTU validation Björn Töpel

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=20260326114919.519456-2-maciej.fijalkowski@intel.com \
    --to=maciej.fijalkowski@intel.com \
    --cc=aleksander.lobakin@intel.com \
    --cc=bjorn@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=larysa.zaremba@intel.com \
    --cc=magnus.karlsson@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    --cc=stfomichev@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox