Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ip, ip6: Fix splice to raw and ping sockets

Splicing to SOCK_RAW sockets may set MSG_SPLICE_PAGES, but in such a case,
__ip_append_data() will call skb_splice_from_iter() to access the 'from'
data, assuming it to point to a msghdr struct with an iter, instead of
using the provided getfrag function to access it.

In the case of raw_sendmsg(), however, this is not the case and 'from' will
point to a raw_frag_vec struct and raw_getfrag() will be the frag-getting
function. A similar issue may occur with rawv6_sendmsg().

Fix this by ignoring MSG_SPLICE_PAGES if getfrag != ip_generic_getfrag as
ip_generic_getfrag() expects "from" to be a msghdr*, but the other getfrags
don't. Note that this will prevent MSG_SPLICE_PAGES from being effective
for udplite.

This likely affects ping sockets too. udplite looks like it should be okay
as it expects "from" to be a msghdr.

Signed-off-by: David Howells <dhowells@redhat.com>
Reported-by: syzbot+d8486855ef44506fd675@syzkaller.appspotmail.com
Link: https://lore.kernel.org/r/000000000000ae4cbf05fdeb8349@google.com/
Fixes: 2dc334f1a63a ("splice, net: Use sendmsg(MSG_SPLICE_PAGES) rather than ->sendpage()")
Tested-by: syzbot+d8486855ef44506fd675@syzkaller.appspotmail.com
cc: David Ahern <dsahern@kernel.org>
cc: Jens Axboe <axboe@kernel.dk>
cc: Matthew Wilcox <willy@infradead.org>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://lore.kernel.org/r/1410156.1686729856@warthog.procyon.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

David Howells and committed by
Jakub Kicinski
5a6f6873 c08afcdc

+4 -2
+2 -1
net/ipv4/ip_output.c
··· 1041 1041 } else if ((flags & MSG_SPLICE_PAGES) && length) { 1042 1042 if (inet->hdrincl) 1043 1043 return -EPERM; 1044 - if (rt->dst.dev->features & NETIF_F_SG) 1044 + if (rt->dst.dev->features & NETIF_F_SG && 1045 + getfrag == ip_generic_getfrag) 1045 1046 /* We need an empty buffer to attach stuff to */ 1046 1047 paged = true; 1047 1048 else
+2 -1
net/ipv6/ip6_output.c
··· 1593 1593 } else if ((flags & MSG_SPLICE_PAGES) && length) { 1594 1594 if (inet_sk(sk)->hdrincl) 1595 1595 return -EPERM; 1596 - if (rt->dst.dev->features & NETIF_F_SG) 1596 + if (rt->dst.dev->features & NETIF_F_SG && 1597 + getfrag == ip_generic_getfrag) 1597 1598 /* We need an empty buffer to attach stuff to */ 1598 1599 paged = true; 1599 1600 else