* [PATCH net v3 0/2] ipv4/ipv6: account for fraggap on paged allocation paths @ 2026-06-11 13:26 Wongi Lee 2026-06-11 13:32 ` [PATCH net v3 1/2] ipv4: account for fraggap on the paged allocation path Wongi Lee 2026-06-11 13:34 ` [PATCH net v3 2/2] ipv6: " Wongi Lee 0 siblings, 2 replies; 5+ messages in thread From: Wongi Lee @ 2026-06-11 13:26 UTC (permalink / raw) To: netdev Cc: David Ahern, Ido Schimmel, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, asml.silence, dhowells, willemb, Jungwoo Lee Fix fraggap accounting in the paged-allocation paths of IPv4 and IPv6. The IPv6 patch is the v3 update of the previously posted patch. The IPv4 patch handles the same code pattern (by Ido). v2->v3 - Add the IPv4 counterpart. - Mention that the IPv6 corruption became triggerable after ce650a166335. - Remove the stale comments about copy becoming -fraggap when pagedlen > 0. - Add missing Cc entries. v1->v2: - Fix mail format. v2: https://lore.kernel.org/netdev/aigx83czv+UJZA0d@DESKTOP-19IMU7U.localdomain/ v1: https://lore.kernel.org/netdev/aibiIYMAwUErTw5U@DESKTOP-19IMU7U.localdomain/ Wongi Lee (2): ipv4: account for fraggap on the paged allocation path ipv6: account for fraggap on the paged allocation path net/ipv4/ip_output.c | 7 ++----- net/ipv6/ip6_output.c | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) -- 2.34.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net v3 1/2] ipv4: account for fraggap on the paged allocation path 2026-06-11 13:26 [PATCH net v3 0/2] ipv4/ipv6: account for fraggap on paged allocation paths Wongi Lee @ 2026-06-11 13:32 ` Wongi Lee 2026-06-15 7:32 ` Ido Schimmel 2026-06-11 13:34 ` [PATCH net v3 2/2] ipv6: " Wongi Lee 1 sibling, 1 reply; 5+ messages in thread From: Wongi Lee @ 2026-06-11 13:32 UTC (permalink / raw) To: netdev Cc: David Ahern, Ido Schimmel, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, asml.silence, dhowells, willemb, Jungwoo Lee In __ip_append_data(), when the paged-allocation branch is taken, alloclen and pagedlen are computed as alloclen = fragheaderlen + transhdrlen; pagedlen = datalen - transhdrlen; datalen already includes fraggap, but the fraggap bytes carried over from the previous skb are copied into the new skb's linear area at offset transhdrlen by the subsequent skb_copy_and_csum_bits(). The linear area is therefore undersized by fraggap bytes while pagedlen is overstated by the same amount. The non-paged branch sets alloclen to fraglen, which already accounts for fraggap because datalen does. Bring the paged branch in line by adding fraggap to alloclen and subtracting it from pagedlen. After this adjustment, copy no longer collapses to -fraggap on the paged path, so remove the stale comment describing that old arithmetic. Fixes: 8eb77cc73977 ("ipv4: avoid partial copy for zc") Signed-off-by: Jungwoo Lee <jwlee2217@gmail.com> Signed-off-by: Wongi Lee <qw3rtyp0@gmail.com> --- net/ipv4/ip_output.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 5bcd73cbdb41..ec790bad1679 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -1117,8 +1117,8 @@ static int __ip_append_data(struct sock *sk, !(rt->dst.dev->features & NETIF_F_SG))) alloclen = fraglen; else { - alloclen = fragheaderlen + transhdrlen; - pagedlen = datalen - transhdrlen; + alloclen = fragheaderlen + transhdrlen + fraggap; + pagedlen = datalen - transhdrlen - fraggap; } alloclen += alloc_extra; @@ -1165,9 +1165,6 @@ static int __ip_append_data(struct sock *sk, } copy = datalen - transhdrlen - fraggap - pagedlen; - /* [!] NOTE: copy will be negative if pagedlen>0 - * because then the equation reduces to -fraggap. - */ if (copy > 0 && INDIRECT_CALL_1(getfrag, ip_generic_getfrag, from, data + transhdrlen, offset, -- 2.34.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net v3 1/2] ipv4: account for fraggap on the paged allocation path 2026-06-11 13:32 ` [PATCH net v3 1/2] ipv4: account for fraggap on the paged allocation path Wongi Lee @ 2026-06-15 7:32 ` Ido Schimmel 0 siblings, 0 replies; 5+ messages in thread From: Ido Schimmel @ 2026-06-15 7:32 UTC (permalink / raw) To: Wongi Lee Cc: netdev, David Ahern, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, asml.silence, dhowells, willemb, Jungwoo Lee On Thu, Jun 11, 2026 at 10:32:39PM +0900, Wongi Lee wrote: > In __ip_append_data(), when the paged-allocation branch is taken, > alloclen and pagedlen are computed as > > alloclen = fragheaderlen + transhdrlen; > pagedlen = datalen - transhdrlen; > > datalen already includes fraggap, but the fraggap bytes carried over > from the previous skb are copied into the new skb's linear area at > offset transhdrlen by the subsequent skb_copy_and_csum_bits(). The > linear area is therefore undersized by fraggap bytes while pagedlen is > overstated by the same amount. > > The non-paged branch sets alloclen to fraglen, which already accounts > for fraggap because datalen does. Bring the paged branch in line by > adding fraggap to alloclen and subtracting it from pagedlen. > > After this adjustment, copy no longer collapses to -fraggap on the > paged path, so remove the stale comment describing that old arithmetic. > > Fixes: 8eb77cc73977 ("ipv4: avoid partial copy for zc") > Signed-off-by: Jungwoo Lee <jwlee2217@gmail.com> > Signed-off-by: Wongi Lee <qw3rtyp0@gmail.com> Reviewed-by: Ido Schimmel <idosch@nvidia.com> ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net v3 2/2] ipv6: account for fraggap on the paged allocation path 2026-06-11 13:26 [PATCH net v3 0/2] ipv4/ipv6: account for fraggap on paged allocation paths Wongi Lee 2026-06-11 13:32 ` [PATCH net v3 1/2] ipv4: account for fraggap on the paged allocation path Wongi Lee @ 2026-06-11 13:34 ` Wongi Lee 2026-06-15 7:30 ` Ido Schimmel 1 sibling, 1 reply; 5+ messages in thread From: Wongi Lee @ 2026-06-11 13:34 UTC (permalink / raw) To: netdev Cc: David Ahern, Ido Schimmel, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, asml.silence, dhowells, willemb, Jungwoo Lee In __ip6_append_data(), when the paged-allocation branch is taken (MSG_MORE / NETIF_F_SG / large fraglen), alloclen and pagedlen are computed as alloclen = fragheaderlen + transhdrlen; pagedlen = datalen - transhdrlen; datalen already includes fraggap (datalen = length + fraggap), but the fraggap bytes carried over from the previous skb are copied into the new skb's linear area at offset transhdrlen by the subsequent skb_copy_and_csum_bits(). The linear area is therefore undersized by fraggap bytes while pagedlen is overstated by the same amount, and the copy writes past skb->end into the trailing skb_shared_info. An unprivileged user can trigger this via a UDPv6 socket using MSG_MORE together with MSG_SPLICE_PAGES. The bad accounting was introduced by commit 773ba4fe9104 ("ipv6: avoid partial copy for zc"). Before commit ce650a166335 ("udp6: Fix __ip6_append_data()'s handling of MSG_SPLICE_PAGES"), the negative copy value caused -EINVAL to be returned. That later commit allowed MSG_SPLICE_PAGES to proceed in this case, making the corruption triggerable. The non-paged branch sets alloclen to fraglen, which already accounts for fraggap because datalen does. Bring the paged branch in line by adding fraggap to alloclen and subtracting it from pagedlen. After this adjustment, copy no longer collapses to -fraggap on the paged path, so remove the stale comment describing that old arithmetic. Fixes: 773ba4fe9104 ("ipv6: avoid partial copy for zc") Signed-off-by: Jungwoo Lee <jwlee2217@gmail.com> Signed-off-by: Wongi Lee <qw3rtyp0@gmail.com> --- net/ipv6/ip6_output.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index c14adcdd4396..bfe16cb8a0aa 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -1668,8 +1668,8 @@ static int __ip6_append_data(struct sock *sk, !(rt->dst.dev->features & NETIF_F_SG))) alloclen = fraglen; else { - alloclen = fragheaderlen + transhdrlen; - pagedlen = datalen - transhdrlen; + alloclen = fragheaderlen + transhdrlen + fraggap; + pagedlen = datalen - transhdrlen - fraggap; } alloclen += alloc_extra; @@ -1684,9 +1684,6 @@ static int __ip6_append_data(struct sock *sk, fraglen = datalen + fragheaderlen; copy = datalen - transhdrlen - fraggap - pagedlen; - /* [!] NOTE: copy may be negative if pagedlen>0 - * because then the equation may reduces to -fraggap. - */ if (copy < 0 && !(flags & MSG_SPLICE_PAGES)) { err = -EINVAL; goto error; -- 2.34.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net v3 2/2] ipv6: account for fraggap on the paged allocation path 2026-06-11 13:34 ` [PATCH net v3 2/2] ipv6: " Wongi Lee @ 2026-06-15 7:30 ` Ido Schimmel 0 siblings, 0 replies; 5+ messages in thread From: Ido Schimmel @ 2026-06-15 7:30 UTC (permalink / raw) To: Wongi Lee Cc: netdev, David Ahern, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, asml.silence, dhowells, willemb, Jungwoo Lee On Thu, Jun 11, 2026 at 10:34:13PM +0900, Wongi Lee wrote: > In __ip6_append_data(), when the paged-allocation branch is taken > (MSG_MORE / NETIF_F_SG / large fraglen), alloclen and pagedlen are > computed as > > alloclen = fragheaderlen + transhdrlen; > pagedlen = datalen - transhdrlen; > > datalen already includes fraggap (datalen = length + fraggap), but > the fraggap bytes carried over from the previous skb are copied into > the new skb's linear area at offset transhdrlen by the subsequent > skb_copy_and_csum_bits(). The linear area is therefore undersized by > fraggap bytes while pagedlen is overstated by the same amount, and > the copy writes past skb->end into the trailing skb_shared_info. Nit: I agree with the conclusion that the linear area is undersized, but "copied into the new skb's linear area at offset transhdrlen" is not accurate: If fraggap is non-zero, this means that this is not the first skb and that the transport header length is zero. We copy the gap bytes just past the fragment headers: data = skb_put(...); data += fragheaderlen; skb_copy_and_csum_bits(..., data + transhdrlen, fraggap) = skb_copy_and_csum_bits(..., data + 0, fraggap) > > An unprivileged user can trigger this via a UDPv6 socket using > MSG_MORE together with MSG_SPLICE_PAGES. > > The bad accounting was introduced by commit 773ba4fe9104 ("ipv6: > avoid partial copy for zc"). Before commit ce650a166335 ("udp6: Fix > __ip6_append_data()'s handling of MSG_SPLICE_PAGES"), the negative > copy value caused -EINVAL to be returned. That later commit allowed > MSG_SPLICE_PAGES to proceed in this case, making the corruption > triggerable. > > The non-paged branch sets alloclen to fraglen, which already accounts > for fraggap because datalen does. Bring the paged branch in line by > adding fraggap to alloclen and subtracting it from pagedlen. > > After this adjustment, copy no longer collapses to -fraggap on the > paged path, so remove the stale comment describing that old arithmetic. > > Fixes: 773ba4fe9104 ("ipv6: avoid partial copy for zc") > Signed-off-by: Jungwoo Lee <jwlee2217@gmail.com> > Signed-off-by: Wongi Lee <qw3rtyp0@gmail.com> Reviewed-by: Ido Schimmel <idosch@nvidia.com> ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-06-15 7:32 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-06-11 13:26 [PATCH net v3 0/2] ipv4/ipv6: account for fraggap on paged allocation paths Wongi Lee 2026-06-11 13:32 ` [PATCH net v3 1/2] ipv4: account for fraggap on the paged allocation path Wongi Lee 2026-06-15 7:32 ` Ido Schimmel 2026-06-11 13:34 ` [PATCH net v3 2/2] ipv6: " Wongi Lee 2026-06-15 7:30 ` Ido Schimmel
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox