LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Eric Biggers <ebiggers3@gmail.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>,
syzbot <syzbot+71d74a5406d02057d559@syzkaller.appspotmail.com>,
alexander.deucher@amd.com,
Andrey Konovalov <andreyknvl@google.com>,
Anoob Soman <anoob.soman@citrix.com>,
chris@chris-wilson.co.uk, David Miller <davem@davemloft.net>,
"Reshetova, Elena" <elena.reshetova@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Kees Cook <keescook@chromium.org>,
LKML <linux-kernel@vger.kernel.org>,
Mike Maloney <maloney@google.com>,
mchehab@kernel.org, netdev <netdev@vger.kernel.org>,
"Rosen, Rami" <rami.rosen@intel.com>,
Sowmini Varadhan <sowmini.varadhan@oracle.com>,
syzkaller-bugs@googlegroups.com,
Willem de Bruijn <willemb@google.com>
Subject: Re: KASAN: use-after-free Read in __dev_queue_xmit
Date: Wed, 9 May 2018 15:21:33 -0400 [thread overview]
Message-ID: <CAF=yD-JPmU-q1iUoxtmyQa4BM=fU3CMR3BUDGNMg-4v8=2_deA@mail.gmail.com> (raw)
In-Reply-To: <CAF=yD-KGO=+=j3yTr4H8cF_WH3RGtnyMDgYRzd7da-r7D=U=GQ@mail.gmail.com>
On Wed, May 9, 2018 at 12:38 PM, Willem de Bruijn
<willemdebruijn.kernel@gmail.com> wrote:
>>> But a crash with the same signature is still occurring, so it should eventually
>>> get reported again. C reproducer is here, it works on Linus' tree (commit
>>> 036db8bd963): https://syzkaller.appspot.com/text?tag=ReproC&x=105b1ae7800000
>>
>> This appears to be a separate issue.
>>
>> This reproducer requires a setsockopt SOL_SOCKET/SO_TIMESTAMPING
>> to trigger the use-after-free. And the freed path also points at a timestamping
>> skb:
>>
>> [ 31.963619] Freed by task 2672:
>> [ 31.964006] __kasan_slab_free+0x125/0x170
>> [ 31.964509] kfree+0x8b/0x1a0
>> [ 31.964875] skb_free_head+0x6f/0xa0
>> [ 31.965314] skb_release_data+0x420/0x5a0
>> [ 31.965802] skb_release_all+0x46/0x60
>> [ 31.966260] kfree_skb+0x91/0x1c0
>> [ 31.966669] __skb_complete_tx_timestamp+0x2e9/0x3d0
>> [ 31.967273] __skb_tstamp_tx+0x3b3/0x620
>> [ 31.967774] __dev_queue_xmit+0xed5/0x1a20
>> [ 31.968300] packet_sendmsg+0x36fd/0x5400
>> [ 31.968821] sock_sendmsg+0xc0/0x100
>> [ 31.969284] ___sys_sendmsg+0x367/0x880
>> [ 31.969777] __sys_sendmmsg+0x178/0x410
>> [ 31.970267] __x64_sys_sendmmsg+0x99/0x100
>> [ 31.970789] do_syscall_64+0x9a/0x2c0
>> [ 31.971260] entry_SYSCALL_64_after_hwframe+0x44/0xa9
>
> This is a rare path taken when the timestamp skb cannot be queued
> onto the socket (likely because of insufficient rcvbuf).
>
> Somehow, freeing the timestamp skb triggers this use-after-free in
> the original skb from which the timestamp was cloned. As if there
> is a bug in the shared info dataref.
Indeed. The skb shared info struct is zeroed by dev_validate_header
as a result of dev->hard_header_len exceeding skb->end - skb->data.
Not exactly sure yet how this can happen. The hard header length space
is accounted for during allocation as reserved memory. But,
packet_alloc_skb does call skb_reserve(), moving skb->data
effectively beyond this reserved region.
It may be incorrect to pass skb->data to dev_validate_header, as that
does not point to the start of the ll_header anymore. Still figuring out what
the right fix is..
next prev parent reply other threads:[~2018-05-09 19:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-04 4:58 syzbot
2018-01-04 5:13 ` Eric Dumazet
2018-01-04 6:53 ` Eric Dumazet
2018-05-09 7:37 ` Eric Biggers
2018-05-09 16:11 ` Willem de Bruijn
2018-05-09 16:38 ` Willem de Bruijn
2018-05-09 19:21 ` Willem de Bruijn [this message]
2018-05-09 19:36 ` Eric Dumazet
2018-05-09 21:05 ` Willem de Bruijn
2018-05-10 21:49 ` Willem de Bruijn
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='CAF=yD-JPmU-q1iUoxtmyQa4BM=fU3CMR3BUDGNMg-4v8=2_deA@mail.gmail.com' \
--to=willemdebruijn.kernel@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=andreyknvl@google.com \
--cc=anoob.soman@citrix.com \
--cc=chris@chris-wilson.co.uk \
--cc=davem@davemloft.net \
--cc=ebiggers3@gmail.com \
--cc=elena.reshetova@intel.com \
--cc=eric.dumazet@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maloney@google.com \
--cc=mchehab@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=rami.rosen@intel.com \
--cc=sowmini.varadhan@oracle.com \
--cc=syzbot+71d74a5406d02057d559@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=willemb@google.com \
--subject='Re: KASAN: use-after-free Read in __dev_queue_xmit' \
/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
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).