linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Dmitry Vyukov <dvyukov@google.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Thomas Graf <tgraf@suug.ch>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Ken-ichirou MATSUZAWA <chamaken@gmail.com>,
	Eric Dumazet <edumazet@google.com>,
	David Herrmann <dh.herrmann@gmail.com>,
	Nicolas Dichtel <nicolas.dichtel@6wind.com>,
	Florian Westphal <fw@strlen.de>, netdev <netdev@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	syzkaller <syzkaller@googlegroups.com>,
	Kostya Serebryany <kcc@google.com>,
	Alexander Potapenko <glider@google.com>,
	Sasha Levin <sasha.levin@oracle.com>,
	netfilter-devel@vger.kernel.org
Subject: Re: net: GPF in netlink_getsockbyportid
Date: Sat, 23 Jan 2016 20:25:02 +0100	[thread overview]
Message-ID: <20160123192502.GB17729@breakpoint.cc> (raw)
In-Reply-To: <CACT4Y+Zmwr0VbfB5RAoLTCJJAF7epZWbbMkHxtXUwvF3tXbrgQ@mail.gmail.com>

Dmitry Vyukov <dvyukov@google.com> wrote:

[ CC nf-devel, not sure if its nfnetlink fault or NETLINK_MMAP ]

> The following program causes GPF in netlink_getsockbyportid:
> 
> // autogenerated by syzkaller (http://github.com/google/syzkaller)
> #include <pthread.h>
> #include <stdint.h>
> #include <string.h>
> #include <sys/syscall.h>
> #include <unistd.h>
> 
> int main()
> {
>   syscall(SYS_mmap, 0x20000000ul, 0xe65000ul, 0x3ul, 0x32ul,
>                  0xfffffffffffffffful, 0x0ul);
>   int fd = syscall(SYS_socket, 0x10ul, 0x803ul, 0xcul, 0, 0, 0);
>   *(uint32_t*)0x20e64000 = (uint32_t)0x28;
>   *(uint32_t*)0x20e64004 = (uint32_t)0x10;
>   *(uint64_t*)0x20e64008 = (uint64_t)0x0;
>   *(uint64_t*)0x20e64010 = (uint64_t)0x3;
>   *(uint64_t*)0x20e64018 = (uint64_t)0xfff;
>   *(uint16_t*)0x20e64020 = (uint16_t)0x5;
>   syscall(SYS_write, fd, 0x20e64000ul, 0x28ul, 0, 0, 0);
>   return 0;
> }

CONFIG_NETLINK_MMAP and nfnetlink batching strike in unison :-/

root cause is in nfnetlink_rcv_batch():

296 replay:
297         status = 0;
298 
299         skb = netlink_skb_clone(oskb, GFP_KERNEL);

The clone op doesn't copy oskb->sk, so we oops in
__netlink_alloc_skb -> netlink_getsockbyportid() when nfnetlink_rcv_batch
tries to send netlink ack.

  reply	other threads:[~2016-01-23 19:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-23 18:24 net: GPF in netlink_getsockbyportid Dmitry Vyukov
2016-01-23 19:25 ` Florian Westphal [this message]
2016-01-23 20:05   ` Daniel Borkmann
2016-01-24  0:11     ` Florian Westphal
2016-01-25 10:03       ` Herbert Xu
2016-01-25 10:17         ` Pablo Neira Ayuso

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=20160123192502.GB17729@breakpoint.cc \
    --to=fw@strlen.de \
    --cc=chamaken@gmail.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=dh.herrmann@gmail.com \
    --cc=dvyukov@google.com \
    --cc=edumazet@google.com \
    --cc=glider@google.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=kcc@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=nicolas.dichtel@6wind.com \
    --cc=sasha.levin@oracle.com \
    --cc=syzkaller@googlegroups.com \
    --cc=tgraf@suug.ch \
    /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).