Re: [BUG] ipv6: splicing a fragmented UDP datagram over an xfrm route warns in __ip6_append_data() and fails with EIO

From: Ido Schimmel

Date: Sun Nov 22 2026 - 03:47:26 EST


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