From: Ido Schimmel <idosch@nvidia.com>
To: Kyuwon Cho <kyuwoncho18@gmail.com>
Cc: David Ahern <dsahern@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
David Howells <dhowells@redhat.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [BUG] ipv6: splicing a fragmented UDP datagram over an xfrm route warns in __ip6_append_data() and fails with EIO
Date: Sun, 22 Nov 2026 10:47:09 +0200 [thread overview]
Message-ID: <20261122084709.GA2656753@shredder> (raw)
In-Reply-To: <179497871649.630760.14878797494884573363@gmail.com>
On Tue, Nov 17, 2026 at 09:11:59PM -0800, Kyuwon Cho wrote:
> Hi David, Ido,
>
> While testing v7.4-rc3 with an LLM-guided test generator that we are
> developing as a research prototype, we found that sendfile() of a UDPv6
> datagram that needs fragmentation, on a route through an xfrm tunnel
> state, hits the WARN_ON_ONCE() in the MSG_SPLICE_PAGES branch of
> __ip6_append_data(), and every such sendfile() fails with EIO:
>
> WARNING: net/ipv6/ip6_output.c:1796 at __ip6_append_data+0x17ed/0x4b70, CPU#0: test/115
> CPU: 0 UID: 65534 PID: 115 Comm: test Not tainted 7.4.0-rc3 #1 PREEMPT(lazy)
> RIP: 0010:__ip6_append_data+0x17ed/0x4b70
> Call Trace:
> <TASK>
> ip6_make_skb+0x24d/0x420
> udpv6_sendmsg+0x1f6f/0x2d70
> sock_sendmsg+0x21f/0x360
> splice_to_socket+0x8fa/0x1180
> direct_splice_actor+0x164/0x6d0
> splice_direct_to_actor+0x2b3/0x990
> do_splice_direct+0x12b/0x1f0
> do_sendfile+0x91b/0xf40
> __x64_sys_sendfile64+0x195/0x1d0
> do_syscall_64+0x116/0x630
> entry_SYSCALL_64_after_hwframe+0x77/0x7f
>
> When __ip6_append_data() starts a new skb for a fragment that is not the
> last one, it treats the dst's trailer space as data space:
>
> if (datalen != length + fraggap) {
> datalen += rt->dst.trailer_len;
> }
>
> On the paged path, pagedlen was computed before that, so with an xfrm
> dst (trailer_len > 0)
>
> copy = datalen - transhdrlen - fraggap - pagedlen;
>
> is trailer_len rather than 0. getfrag() then copies those bytes from the
> message iterator into the linear part, but the branch right after it
> also runs when getfrag() succeeds:
>
> if (copy > 0 &&
> INDIRECT_CALL_1(getfrag, ip_generic_getfrag,
> from, data + transhdrlen, offset,
> copy, fraggap, skb) < 0) {
> ...
> } else if (flags & MSG_SPLICE_PAGES) {
> copy = 0;
> }
>
> offset += copy;
> length -= copy + transhdrlen;
>
> so length stays trailer_len larger than what is left in msg->msg_iter.
> On the next pass the splice branch finds copy > msg->msg_iter.count,
> warns and returns -EIO. IPv4 is not affected: __ip_append_data() does
> not add trailer_len to datalen, so copy is 0 there.
>
> The branch dates from ce650a166335 ("udp6: Fix __ip6_append_data()'s
> handling of MSG_SPLICE_PAGES"), when copy could be negative on this
> path. Since 736b380e28d0 ("ipv6: account for fraggap on the paged
> allocation path") a negative copy returns -EINVAL before this point, so
> dropping the branch should be enough. With it removed, the reproducer
> runs clean in 6 of 6 runs and all its sendfile() calls succeed, where
> they all fail with EIO before.
Please send this fix with the following tag:
Fixes: ce650a166335 ("udp6: Fix __ip6_append_data()'s handling of MSG_SPLICE_PAGES")
Thanks
prev parent reply other threads:[~2026-11-22 8:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 5:11 [BUG] ipv6: splicing a fragmented UDP datagram over an xfrm route warns in __ip6_append_data() and fails with EIO Kyuwon Cho
2026-11-22 8:47 ` Ido Schimmel [this message]
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=20261122084709.GA2656753@shredder \
--to=idosch@nvidia.com \
--cc=davem@davemloft.net \
--cc=dhowells@redhat.com \
--cc=dsahern@kernel.org \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kyuwoncho18@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/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