Skip to content

Commit 398708d

Browse files
PlaidCatbmastbergen
authored andcommitted
xfrm: esp: avoid in-place decrypt on shared skb frags
jira VULN-184831 cve CVE-2026-43284 commit-author Kuan-Ting Chen <h3xrabbit@gmail.com> commit f4c50a4 upstream-diff | While this kernel lacks MSG_SPLICE_PAGES, it still has udp_sendpage(). Upstream didn't patch udp_sendpage() because sendpage was removed entirely in favor of MSG_SPLICE_PAGES. In this kernel, splice() can still attach a page cache page to an IPv4 datagram via sendpage. Therefore, udp_sendpage() must be patched instead. IPv6 does not have MSG_SPLICE_PAGES but the __ip_addend_data() path is exercisable in ipv6/esp6.c so we're including that block. Due to missing 06b4feb ("net: group skb_shinfo zerocopy related bits together.") SKBFL_SHARED_FRAG was replaced with SKBTX_SHARED_FRAG. Also replaced flags with tx_flags. MSG_SPLICE_PAGES can attach pages from a pipe directly to an skb. TCP marks such skbs with SKBFL_SHARED_FRAG after skb_splice_from_iter(), so later paths that may modify packet data can first make a private copy. The IPv4/IPv6 datagram append paths did not set this flag when splicing pages into UDP skbs. That leaves an ESP-in-UDP packet made from shared pipe pages looking like an ordinary uncloned nonlinear skb. ESP input then takes the no-COW fast path for uncloned skbs without a frag_list and decrypts in place over data that is not owned privately by the skb. Mark IPv4/IPv6 datagram splice frags with SKBFL_SHARED_FRAG, matching TCP. Also make ESP input fall back to skb_cow_data() when the flag is present, so ESP does not decrypt externally backed frags in place. Private nonlinear skb frags still use the existing fast path. This intentionally does not change ESP output. In esp_output_head(), the path that appends the ESP trailer to existing skb tailroom without calling skb_cow_data() is not reachable for nonlinear skbs: skb_tailroom() returns zero when skb->data_len is nonzero, while ESP tailen is positive. Thus ESP output will either use the separate destination-frag path or fall back to skb_cow_data(). Fixes: cac2661 ("esp4: Avoid skb_cow_data whenever possible") Fixes: 03e2a30 ("esp6: Avoid skb_cow_data whenever possible") Fixes: 7da0dde ("ip, udp: Support MSG_SPLICE_PAGES") Fixes: 6d8192b ("ip6, udp6: Support MSG_SPLICE_PAGES") Reported-by: Hyunwoo Kim <imv4bel@gmail.com> Reported-by: Kuan-Ting Chen <h3xrabbit@gmail.com> Tested-by: Hyunwoo Kim <imv4bel@gmail.com> Cc: stable@vger.kernel.org Signed-off-by: Kuan-Ting Chen <h3xrabbit@gmail.com> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com> (cherry picked from commit f4c50a4) Signed-off-by: Shreeya Patel <spatel@ciq.com> Signed-off-by: Roxana Nicolescu <rnicolescu@ciq.com> Signed-off-by: Joanthan Maple <jmaple@ciq.com>
1 parent c63bd9b commit 398708d

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

net/ipv4/esp4.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,8 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb)
913913
nfrags = 1;
914914

915915
goto skip_cow;
916-
} else if (!skb_has_frag_list(skb)) {
916+
} else if (!skb_has_frag_list(skb) &&
917+
!skb_has_shared_frag(skb)) {
917918
nfrags = skb_shinfo(skb)->nr_frags;
918919
nfrags++;
919920

net/ipv4/ip_output.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,6 +1333,9 @@ ssize_t ip_append_page(struct sock *sk, struct flowi4 *fl4, struct page *page,
13331333
goto error;
13341334
}
13351335

1336+
if (!(flags & MSG_NO_SHARED_FRAGS))
1337+
skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG;
1338+
13361339
if (skb->ip_summed == CHECKSUM_NONE) {
13371340
__wsum csum;
13381341
csum = csum_page(page, offset, len);

net/ipv6/esp6.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,8 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
971971
nfrags = 1;
972972

973973
goto skip_cow;
974-
} else if (!skb_has_frag_list(skb)) {
974+
} else if (!skb_has_frag_list(skb) &&
975+
!skb_has_shared_frag(skb)) {
975976
nfrags = skb_shinfo(skb)->nr_frags;
976977
nfrags++;
977978

0 commit comments

Comments
 (0)