From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796379631; b=bRfjLRVHPgkuo8vN8hpqAtCFeif5tsdif+KdC639obU4P+1yDtqJDrJDOCUFeuXECXxa meEXE2k/gUN9daxthWPcPXXZRoulI075wcbzSkwldjDL4qO0BUpYq9OD2mP8lYRRntGbp jCgu1F1Oa1b3joKTSNNmL9FqNlvGoNm89fezpB8rrAGHvDnGtdtM/CnrklWUuFOs4ZHLJ Tx0BciFu+E6GWJok4K/CtnL+SB8PNLjuIIAoSG9DWVNoZGYiMvzAT+rbMYKaet81QwArc TS3+32Z3j04oK6mA90/8bclLCplNdTs0onc/0F2ufUudIUXgEwUt8Xkcj2DwPJ+V4Cg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379631; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=AU/AD2KejqsO0NVq7THvtct9XfUIGDJAwMiEhDwyyps=; b=hv76f4xLUMYW0z8k3ajiBObOgBs4cw4cm3532HAbPeAK+VMlexGiitRdlljHYggRwjys mwkM80bPzMwHPibu3gnzMhDLLwALzlOdfZaeCGgXhDBn8JZ9YtjijTFbzonKf2mmDK76w d03xhCxMvPJavsRAZE6/ySz/ft1B/kIwAlIaW9ZS7e8vJr1g1MYdJU/6z+VFGn0aaKsDD ZxLlqDmCq9Nt/8PbD2eH4LyO+tRb3iHEiQ2DqzRdVbzBTw30/Js4gUzH6U4lX7QN1L1sp +wCheyQZflvZdyUlksZY1opZcwhOSGIgSkJp6oFPK3OBmV9zCC/QyR7IynU5Ia53GaQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=OAdZHowh; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE7F1606A322; Fri, 4 Dec 2026 10:20:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=OAdZHowh Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2ABC1F000C2; Fri, 4 Dec 2026 10:20:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796379631; bh=AU/AD2KejqsO0NVq7THvtct9XfUIGDJAwMiEhDwyyps=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=OAdZHowhijgix9VPZEEbdrJgUrwk4OqfxL2LFKHvhlzNjnQtHqVDHtwwE1Xq+Zf/l qXDf0KAlGYaZFII6o3rvyLedrcQ3pfZC+38fj54kbIYqPGhElwHi6PEx+HWM4fHycg DThW0G5//4i2DigjYiNRurBuEaokRxb07y4a+IKs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alexei Starovoitov , Sasha Levin Subject: [PATCH 6.1 0046/1059] bpf: Dont let bpf_skb_adjust_room() raise gso_size to GSO_BY_FRAGS Date: Fri, 4 Dec 2026 18:52:57 +0900 Message-ID: <20261204100645.251377477@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alexei Starovoitov [ Upstream commit 6d8118937ba477e03fa2e94e9bd9abac7291a2a2 ] When bpf_skb_adjust_room() shrinks a TCP GSO skb, it adds the number of removed bytes to gso_size. gso_size has 16 bits, and nothing checks the sum. Thus gso_size can wrap to 0 or to a small size, or it can be GSO_BY_FRAGS. GSO_BY_FRAGS is not a size. It tells skb_segment() to read the length of each segment from the frag_list. If the TCP GSO skb has no frag_list, skb_segment() dereferences a NULL pointer. Return -ENOTSUPP and do not change the skb if the sum is GSO_BY_FRAGS or larger. With BPF_F_ADJ_ROOM_FIXED_GSO the helper does not change gso_size, so it shrinks the skb as before. Fixes: 2be7e212d541 ("bpf: add bpf_skb_adjust_room helper") Signed-off-by: Alexei Starovoitov Link: https://patch.msgid.link/20261101190535.1454146-16-alexei.starovoitov@gmail.com Signed-off-by: Sasha Levin --- net/core/filter.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/core/filter.c b/net/core/filter.c index 4872f5c27cf5b..b3582a59e3dda 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -3653,6 +3653,14 @@ static int bpf_skb_net_shrink(struct sk_buff *skb, u32 off, u32 len_diff, return -ENOTSUPP; } + /* + * The MSS is raised by len_diff. It has 16 bits, and GSO_BY_FRAGS is + * not a size. + */ + if (skb_is_gso(skb) && !(flags & BPF_F_ADJ_ROOM_FIXED_GSO) && + skb_shinfo(skb)->gso_size + len_diff >= GSO_BY_FRAGS) + return -ENOTSUPP; + ret = skb_unclone(skb, GFP_ATOMIC); if (unlikely(ret < 0)) return ret; -- 2.53.0