Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev, Alexei Starovoitov <ast@kernel.org>,
	Sasha Levin <sashal@kernel.org>
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	[thread overview]
Message-ID: <20261204100645.251377477@linuxfoundation.org> (raw)
In-Reply-To: <20261204100643.980430235@linuxfoundation.org>

6.1-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Alexei Starovoitov <ast@kernel.org>

[ 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 <ast@kernel.org>
Link: https://patch.msgid.link/20261101190535.1454146-16-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 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




  parent reply	other threads:[~2026-12-04 10:20 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  9:52 [PATCH 6.1 0000/1059] 6.1.194-rc1 review Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0001/1059] RDMA/erdma: Use IRQ-safe XArray helpers for QP and CQ tables Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0002/1059] netfilter: nft_ct: expectation timeouts are passed in milliseconds Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0003/1059] netfilter: nft_ct: move custom expectation support to helper Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0004/1059] mm/khugepaged: preserve dirty bits when collapsing PTE-mapped THPs Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0005/1059] drm/amdgpu: Check cs flags Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0006/1059] bpf: Drop inet_conn_established from lsm sleepable hooks Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0007/1059] mm: page_alloc: remove ALLOC_NON_BLOCK from ALLOC_RESERVES Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0008/1059] irqchip/sifive-plic: Avoid signed shift in interrupt enable mask Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0009/1059] fs: aio: reject partial mremap to avoid Null-pointer-dereference error Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0010/1059] Revert "SUNRPC: svcauth_gss: enforce krb5 token minimum length" Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0011/1059] Revert "SUNRPC: Convert unwrap_priv_data() to use xdr_stream" Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0012/1059] SUNRPC: svcauth_gss: enforce krb5 token minimum length Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0013/1059] mm/ksm: simplify break_ksm() to not rely on VM_FAULT_WRITE Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0014/1059] mm/ksm: fix KSM COW breaking with userfaultfd-wp via FAULT_FLAG_UNSHARE Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0015/1059] mm/ksm: fix userfaultfd protection during merge and unmerge Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0016/1059] udf: validate VAT inode size for old VAT format Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0017/1059] udf: validate vat20->lengthHeader and VAT inode size in udf_load_vat() Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0018/1059] io_uring: enable toggle of iowait usage when waiting on CQEs Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0019/1059] io_uring: fail soft links on negative IOU_COMPLETE results Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0020/1059] io_uring/rw: fail soft links on IOPOLL short or error IO Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0021/1059] io_uring/rsrc: keep the old file when a file update fails Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0022/1059] Input: destroy force-feedback device on input unregistration Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0023/1059] staging: media: atomisp: use array3_size() for overflow-safe allocation Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0024/1059] fs/9p: switch vfsmount to use v9fs_get_new_inode Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0025/1059] fs/9p: rework qid2ino logic Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0026/1059] 9p: skip intermediate directory entry name copy in p9dirent_read() Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0027/1059] xfrm: zero-initialise km_event in the replay-notify path Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0028/1059] batman-adv: avoid WARN_ON for orig_ifinfo allocation failure Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0029/1059] wifi: ath9k_htc: start ANI when an AP interface begins to beacon Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0030/1059] scsi: aic7xxx: Fix REQUEST SENSE allocation length on big-endian hosts Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0031/1059] scsi: aha1542: Remove unneeded scsi_dma_unmap() call Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0032/1059] wifi: ath10k: Stop unanswered temperature reads Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0033/1059] seg6: fix transport header for inner IPv4 with IP options Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0034/1059] gpio: omap: Propagate runtime PM failures in probe and request Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0035/1059] btrfs: verity: propagate orphan insertion errors when enabling verity Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0036/1059] btrfs: scrub: fix lost wakeup and hang when cancelling a scrub that is finishing Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0037/1059] btrfs: zoned: fix double free of bitmaps on clone failure Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0038/1059] ptp: drain virtual clock sysfs operations before unregistering children Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0039/1059] ptp: unwind partially completed virtual clock creation Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0040/1059] ptp: prevent possible ABBA deadlock in ptp_clock_freerun() Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0041/1059] ptp: vclock: propagate physical clock sampling errors Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0042/1059] ptp: vclock: serialize extended samples with counter updates Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0043/1059] scsi: target: Validate REGISTER AND MOVE TransportID length Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0044/1059] tipc: reject attaching bearer of different media to the same occupied device Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0045/1059] spi: pic32-sqi: fail transfer when the BD ring is exhausted Greg Kroah-Hartman
2026-12-04  9:52 ` Greg Kroah-Hartman [this message]
2026-12-04  9:52 ` [PATCH 6.1 0047/1059] bpf: Reject non-IPv6 packets in BPF_LWT_ENCAP_SEG6 Greg Kroah-Hartman
2026-12-04  9:52 ` [PATCH 6.1 0048/1059] bpf: Limit the SRH length in bpf_lwt_seg6_adjust_srh() Greg Kroah-Hartman
2026-12-04  9:53 ` [PATCH 6.1 0049/1059] bpf: Dont look for the SRH again in the End.BPF helpers Greg Kroah-Hartman
2026-12-04  9:53 ` [PATCH 6.1 0050/1059] bpf: Move the MAC header in bpf_lwt_seg6_adjust_srh() Greg Kroah-Hartman
2026-12-04  9:53 ` [PATCH 6.1 0051/1059] bpf: Dont leave a stale MAC header in bpf_lwt_push_ip_encap() Greg Kroah-Hartman
2026-12-04  9:53 ` [PATCH 6.1 0052/1059] ipv4: Unmask upper DSCP bits in input route lookup Greg Kroah-Hartman
2026-12-04  9:53 ` [PATCH 6.1 0053/1059] ipv4: Convert ip_route_input_noref() to dscp_t Greg Kroah-Hartman
2026-12-04  9:53 ` [PATCH 6.1 0054/1059] bpf: Reset skb->cb after an lwt prog pushes an IP header Greg Kroah-Hartman
2026-12-04  9:53 ` [PATCH 6.1 0055/1059] bpf: Require BPF_LWT_REROUTE when an lwt_in prog changes the protocol Greg Kroah-Hartman
2026-12-04  9:53 ` [PATCH 6.1 0056/1059] bpf: Move the transport header with the moved headers Greg Kroah-Hartman
2026-12-04  9:53 ` [PATCH 6.1 0057/1059] bpf: Check the offset in bpf_skb_generic_{push,pop}() Greg Kroah-Hartman
2026-12-04  9:53 ` [PATCH 6.1 0058/1059] spi: Fix ACPI SPI resources using relative path Greg Kroah-Hartman
2026-12-04  9:53 ` [PATCH 6.1 0059/1059] spi: acpi: only look up the IRQ of confirmed SPI devices Greg Kroah-Hartman

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=20261204100645.251377477@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=ast@kernel.org \
    --cc=patches@lists.linux.dev \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    /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