Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1315740
| From | Daniel Borkmann <daniel@iogearbox.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: net: GPF in netlink_getsockbyportid |
| Date | 2016-01-23 21:10 +0100 |
| Message-ID | <qUcFs-7XM-7@gated-at.bofh.it> (permalink) |
| References | <qUb6G-6FS-7@gated-at.bofh.it> <qUc2K-7pM-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 01/23/2016 08:25 PM, Florian Westphal wrote:
> 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.
If indeed oskb is the mmap'ed netlink skb, then it's not even allowed
to call into skb_clone() as it would access skb shared info data that
can be controlled by the user space mmap buffer, iirc, we had that in
the past with nlmon where skb_clone() was accidentally used.
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
net: GPF in netlink_getsockbyportid Dmitry Vyukov <dvyukov@google.com> - 2016-01-23 19:30 +0100
Re: net: GPF in netlink_getsockbyportid Florian Westphal <fw@strlen.de> - 2016-01-23 20:30 +0100
Re: net: GPF in netlink_getsockbyportid Daniel Borkmann <daniel@iogearbox.net> - 2016-01-23 21:10 +0100
Re: net: GPF in netlink_getsockbyportid Florian Westphal <fw@strlen.de> - 2016-01-24 01:20 +0100
Re: net: GPF in netlink_getsockbyportid Herbert Xu <herbert@gondor.apana.org.au> - 2016-01-25 11:10 +0100
Re: net: GPF in netlink_getsockbyportid Pablo Neira Ayuso <pablo@netfilter.org> - 2016-01-25 11:20 +0100
csiph-web