From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EAB1E3B3C01; Sat, 30 May 2026 17:37:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780162681; cv=none; b=MEgZVzVsFJvE5xxnOxRlABY2LCX1EN9u5VYcJ05GzYKFI4Q85UoYLyA2lNwyV5dCbtFNJOA8JtPP+y97kW7/M/61w9YVSyAxoGCmZwy8OfIca40p0gdXyVVppZQzVnLb4frIUmaoogI/em4KCNwzkt67gPbOUGpTeGD8UjsiFJU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780162681; c=relaxed/simple; bh=O5sIEyDtXDG3HFZXwR+BpfycQCd221DyI59ixiXADOg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=crp2DQ0DQ8b4o7aoEqxumV34S4gL61paR/6Twc5vAHjaKo20r/fjHh0DLt4oy/FuSfja55MkzZsrZEAR8tsCW0RA3zMU62RcJJzhC4l9d01GZO3prk6OrDQtyKclQugRWB7uGv76ytoBKfXap9mfTYKFibJOjmyiPKXXapNGOCw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=N/FOMU7b; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="N/FOMU7b" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C5011F00893; Sat, 30 May 2026 17:37:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780162679; bh=GK1DmSRTA9w7ffK/vkPkC+EG1ux/q9cXStmBDQk8q/w=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=N/FOMU7bdp0JHiGMeKw4G/nBIHestn4kXt9b1AWRBy6sentiGm7Oxd70E1k4CENc7 D9Bopq4dLpiDyyOroUY6S4I78BTF8e9Zvi3Rk9Ty5VsjeP/W9R1oTSc8/jxnjxnNBh /WL6Uf+564QR1ui8FuVTXDWV1lQva7IrqwK8YnaQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Stanislav Fomichev , Maciej Fijalkowski , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 031/776] xsk: tighten UMEM headroom validation to account for tailroom and min frame Date: Sat, 30 May 2026 17:55:45 +0200 Message-ID: <20260530160241.079868658@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160240.228940103@linuxfoundation.org> References: <20260530160240.228940103@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Maciej Fijalkowski [ Upstream commit a315e022a72d95ef5f1d4e58e903cb492b0ad931 ] 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 Acked-by: Stanislav Fomichev Fixes: 99e3a236dd43 ("xsk: Add missing check on user supplied headroom size") Signed-off-by: Maciej Fijalkowski Link: https://patch.msgid.link/20260402154958.562179-2-maciej.fijalkowski@intel.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- 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 65f918d29531d..f247fc4de9e10 100644 --- a/net/xdp/xdp_umem.c +++ b/net/xdp/xdp_umem.c @@ -198,7 +198,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; umem->size = size; -- 2.53.0