netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: syzbot <syzbot+d8486855ef44506fd675@syzkaller.appspotmail.com>
Cc: dhowells@redhat.com, bpf@vger.kernel.org, davem@davemloft.net,
	dsahern@kernel.org, edumazet@google.com, kuba@kernel.org,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	pabeni@redhat.com, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [net?] KASAN: stack-out-of-bounds Read in skb_splice_from_iter
Date: Wed, 14 Jun 2023 00:59:48 +0100	[thread overview]
Message-ID: <1394611.1686700788@warthog.procyon.org.uk> (raw)
In-Reply-To: <000000000000ae4cbf05fdeb8349@google.com>

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git main

commit b49195695a78f1fb56ecbfd3c3fd14dbe6844088
Author: David Howells <dhowells@redhat.com>
Date:   Wed Jun 14 00:14:32 2023 +0100

    ip, ip6: Handle 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()")
    cc: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
    cc: David Ahern <dsahern@kernel.org>
    cc: "David S. Miller" <davem@davemloft.net>
    cc: Eric Dumazet <edumazet@google.com>
    cc: Jakub Kicinski <kuba@kernel.org>
    cc: Paolo Abeni <pabeni@redhat.com>
    cc: Jens Axboe <axboe@kernel.dk>
    cc: Matthew Wilcox <willy@infradead.org>
    cc: netdev@vger.kernel.org

diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 244fb9365d87..4b39ea99f00b 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -1040,7 +1040,8 @@ static int __ip_append_data(struct sock *sk,
 	} else if ((flags & MSG_SPLICE_PAGES) && length) {
 		if (inet->hdrincl)
 			return -EPERM;
-		if (rt->dst.dev->features & NETIF_F_SG)
+		if (rt->dst.dev->features & NETIF_F_SG &&
+		    getfrag == ip_generic_getfrag)
 			/* We need an empty buffer to attach stuff to */
 			paged = true;
 		else
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index c722cb881b2d..dd845139882c 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1592,7 +1592,8 @@ static int __ip6_append_data(struct sock *sk,
 	} else if ((flags & MSG_SPLICE_PAGES) && length) {
 		if (inet_sk(sk)->hdrincl)
 			return -EPERM;
-		if (rt->dst.dev->features & NETIF_F_SG)
+		if (rt->dst.dev->features & NETIF_F_SG &&
+		    getfrag == ip_generic_getfrag)
 			/* We need an empty buffer to attach stuff to */
 			paged = true;
 		else


  parent reply	other threads:[~2023-06-13 23:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-12  9:40 [syzbot] [net?] KASAN: stack-out-of-bounds Read in skb_splice_from_iter syzbot
2023-06-13 18:15 ` Jakub Kicinski
2023-06-13 18:45   ` David Howells
2023-06-13 23:59 ` David Howells [this message]
2023-06-14  0:20   ` syzbot

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=1394611.1686700788@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=bpf@vger.kernel.org \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=syzbot+d8486855ef44506fd675@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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;
as well as URLs for NNTP newsgroup(s).