kernel/1103-net-skbuff-propagate-shared-frag-marker.patch
Andrew Lukoshko b3c4cf07f6 Bump version to 6.12.0-211.7.4
Refresh the dirtyfrag backport to upstream v5 and add the cifs.spnego
hardening patch.

  1103-net-skbuff-propagate-shared-frag-marker.patch
    Refreshed from upstream v3 to v5
    (https://lore.kernel.org/all/ageeJfJHwgzmKXbh@v4bel/). The v5
    series adds three hunks on top of v3: two skb_segment() sites
    (fold frag_skb-> flags into nskb on the per-iteration flag merge;
    fill the marker again when the inner switch rebinds frag_skb on
    head_skb-frags exhaustion) and one tcp_clone_payload() site
    (carry the marker when building an MTU probe skb from sk_write_queue
    frag descriptors). skb_try_coalesce() hunk is retained as in v3/v4
    because the upstream commit that dropped it (f84eca581739) is only
    partially backported in 6.12 -- its skb_split() half is present,
    but the skb_try_coalesce() half is missing.

  1105-smb-client-reject-userspace-cifs.spnego-descriptions.patch
    Upstream commit 3da1fdf4efbc verbatim. Refuses userspace-created
    cifs.spnego keys via request_key(2)/add_key(2); only kernel CIFS
    using the private spnego_cred may create them. cifs.upcall
    treats the key description as kernel-originating
    pid/uid/creduid/upcall_target -- without this fence, userspace
    can spoof those fields.

All five patches verified to apply with patch -p1 -F0 against the
6.12.0-211.7.1.el10_2 source tree (no fuzz, no rejects).
2026-05-28 11:55:58 +00:00

148 lines
5.8 KiB
Diff

From: Andrew Lukoshko <alukoshko@almalinux.org>
Subject: [PATCH AlmaLinux 10] net: skbuff: propagate shared-frag marker through frag-transfer helpers
Backport of upstream v5 patch posted at
https://lore.kernel.org/all/ageeJfJHwgzmKXbh@v4bel/
(sibling to upstream commit f4c50a4034e6 "xfrm: esp: avoid in-place
decrypt on shared skb frags").
Three frag-transfer helpers in net/core/skbuff.c
(__pskb_copy_fclone(), skb_try_coalesce(), skb_shift()) and the two
GRO accumulator helpers in net/core/gro.c (skb_gro_receive() and
skb_gro_receive_list()) fail to propagate the SKBFL_SHARED_FRAG bit
in skb_shinfo()->flags when moving frag descriptors from source to
destination. In addition, skb_segment() folds only head_skb's flag
into nskb on the per-iteration flag merge, and the inner switch that
rebinds frag_skb to list_skb on head_skb-frags exhaustion does not
fold the new frag_skb's flag into nskb. Finally,
tcp_clone_payload() builds an MTU probe skb by moving frag
descriptors from sk_write_queue skbs into a fresh nskb without
propagating the marker. As a result, the destination skb keeps a
reference to the same externally-owned or page-cache-backed pages
while reporting skb_has_shared_frag() as false.
The mismatch is harmful in any in-place writer that uses
skb_has_shared_frag() to decide whether shared pages must be detoured
through skb_cow_data(). ESP input is one such writer (esp4.c,
esp6.c). Combined with an nft 'dup to <local>' rule, an
nf_dup_ipv4() / xt_TEE caller, or ESP-over-UDP with UDP GRO, this
lets an unprivileged user write into the page cache of a root-owned
read-only file via authencesn-ESN stray writes (CVE-2026-46300,
"Fragnesia").
Set SKBFL_SHARED_FRAG on the destination whenever frag descriptors
were actually moved from the source. skb_copy() and skb_copy_expand()
share skb_copy_header() too but linearize all paged data into freshly
allocated head storage and emerge with nr_frags == 0, so
skb_has_shared_frag() returns false on its own; they need no change.
The same omission exists in skb_gro_receive() and
skb_gro_receive_list(). The former moves the incoming skb's frag
descriptors into the accumulator's last sub-skb via two paths plus a
"merge:" fallback that chains the whole skb onto frag_list; the
latter chains the incoming skb whole onto p's frag_list. Downstream
skb_segment() reads only skb_shinfo(p)->flags, and skb_segment_list()
reuses each sub-skb's shinfo as the nskb -- both p and lp must carry
the marker.
skb_try_coalesce() hunk: upstream v5 drops the v3/v4 skb_try_coalesce()
change because commit f84eca581739 ("net: account for SKBFL_SHARED_FRAG
in skb_split() and skb_try_coalesce()") covers that site there. Only
the skb_split() half of f84eca581739 is currently backported in 6.12,
so the skb_try_coalesce() hunk is retained here to close the same gap.
Fixes: cef401de7be8 ("net: fix possible wrong checksum generation")
Fixes: f4c50a4034e6 ("xfrm: esp: avoid in-place decrypt on shared skb frags")
Reported-by: Sultan Alsawaf <sultan@kerneltoast.com>
Reported-by: William Bowling <vakzz@zellic.io>
Reported-by: Hyunwoo Kim <imv4bel@gmail.com>
Signed-off-by: Andrew Lukoshko <alukoshko@almalinux.org>
---
net/core/gro.c | 4 ++++
net/core/skbuff.c | 14 +++++++++++++-
net/ipv4/tcp_output.c | 1 +
3 files changed, 18 insertions(+), 1 deletion(-)
--- a/net/core/skbuff.c 2026-05-28 13:12:16.410047140 +0200
+++ b/net/core/skbuff.c 2026-05-28 13:17:15.081411917 +0200
@@ -2123,6 +2123,7 @@
skb_frag_ref(skb, i);
}
skb_shinfo(n)->nr_frags = i;
+ skb_shinfo(n)->flags |= skb_shinfo(skb)->flags & SKBFL_SHARED_FRAG;
}
if (skb_has_frag_list(skb)) {
@@ -4198,6 +4199,8 @@
tgt->ip_summed = CHECKSUM_PARTIAL;
skb->ip_summed = CHECKSUM_PARTIAL;
+ skb_shinfo(tgt)->flags |= skb_shinfo(skb)->flags & SKBFL_SHARED_FRAG;
+
skb_len_add(skb, -shiftlen);
skb_len_add(tgt, shiftlen);
@@ -4808,7 +4811,8 @@
skb_copy_from_linear_data_offset(head_skb, offset,
skb_put(nskb, hsize), hsize);
- skb_shinfo(nskb)->flags |= skb_shinfo(head_skb)->flags &
+ skb_shinfo(nskb)->flags |= (skb_shinfo(head_skb)->flags |
+ skb_shinfo(frag_skb)->flags) &
SKBFL_SHARED_FRAG;
if (skb_zerocopy_clone(nskb, frag_skb, GFP_ATOMIC))
@@ -4825,6 +4829,9 @@
nfrags = skb_shinfo(list_skb)->nr_frags;
frag = skb_shinfo(list_skb)->frags;
frag_skb = list_skb;
+
+ skb_shinfo(nskb)->flags |= skb_shinfo(frag_skb)->flags & SKBFL_SHARED_FRAG;
+
if (!skb_headlen(list_skb)) {
BUG_ON(!nfrags);
} else {
@@ -6030,6 +6037,8 @@
from_shinfo->frags,
from_shinfo->nr_frags * sizeof(skb_frag_t));
to_shinfo->nr_frags += from_shinfo->nr_frags;
+ if (from_shinfo->nr_frags)
+ to_shinfo->flags |= from_shinfo->flags & SKBFL_SHARED_FRAG;
if (!skb_cloned(from))
from_shinfo->nr_frags = 0;
--- a/net/core/gro.c 2026-05-28 13:12:16.409094447 +0200
+++ b/net/core/gro.c 2026-05-28 13:15:11.599892601 +0200
@@ -214,10 +214,12 @@
p->data_len += len;
p->truesize += delta_truesize;
p->len += len;
+ skb_shinfo(p)->flags |= skbinfo->flags & SKBFL_SHARED_FRAG;
if (lp != p) {
lp->data_len += len;
lp->truesize += delta_truesize;
lp->len += len;
+ skb_shinfo(lp)->flags |= skbinfo->flags & SKBFL_SHARED_FRAG;
}
NAPI_GRO_CB(skb)->same_flow = 1;
return 0;
@@ -245,6 +247,8 @@
p->truesize += skb->truesize;
p->len += skb->len;
+ skb_shinfo(p)->flags |= skb_shinfo(skb)->flags & SKBFL_SHARED_FRAG;
+
NAPI_GRO_CB(skb)->same_flow = 1;
return 0;
--- a/net/ipv4/tcp_output.c 2026-05-28 13:12:16.846070054 +0200
+++ b/net/ipv4/tcp_output.c 2026-05-28 13:14:19.646400034 +0200
@@ -2380,6 +2380,7 @@
todo = min_t(int, skb_frag_size(fragfrom),
probe_size - len);
len += todo;
+ skb_shinfo(to)->flags |= skb_shinfo(skb)->flags & SKBFL_SHARED_FRAG;
if (lastfrag &&
skb_frag_page(fragfrom) == skb_frag_page(lastfrag) &&
skb_frag_off(fragfrom) == skb_frag_off(lastfrag) +