From: John Fastabend <john.fastabend@gmail.com>
To: Daniel Borkmann <daniel@iogearbox.net>, ast@kernel.org
Cc: netdev@vger.kernel.org
Subject: Re: [bpf-next PATCH] bpf: sockhash fix race with bpf_tcp_close and map delete
Date: Sat, 26 May 2018 21:36:16 -0700 [thread overview]
Message-ID: <26e7a154-9d7d-8547-4c39-dd85d72efaa0@gmail.com> (raw)
In-Reply-To: <1a7bab54-809a-dae4-a0f7-ea1fab2e8c7a@iogearbox.net>
On 05/26/2018 01:30 AM, Daniel Borkmann wrote:
> Hi John,
>
> On 05/25/2018 07:37 PM, John Fastabend wrote:
>> syzbot reported two related splats, a use after free and null
>> pointer dereference, when a TCP socket is closed while the map is
>> also being removed.
>>
>> The psock keeps a reference to all map slots that have a reference
>> to the sock so that when the sock is closed we can clean up any
>> outstanding sock{map|hash} entries. This avoids pinning a sock
>> forever if the map owner fails to do proper cleanup. However, the
>> result is we have two paths that can free an entry in the map. Even
>> the comment in the sock{map|hash} tear down function, sock_hash_free()
>> notes this:
>>
>> At this point no update, lookup or delete operations can happen.
>> However, be aware we can still get a socket state event updates,
>> and data ready callbacks that reference the psock from sk_user_data.
>>
>> Both removal paths omitted taking the hash bucket lock resulting
>> in the case where we have two references that are in the process
>> of being free'd.
>>
>> Reported-by: syzbot+a761b81c211794fa1072@syzkaller.appspotmail.com
>> Signed-off-by: John Fastabend <john.fastabend@gmail.com>
>
Fixes: 81110384441a ("bpf: sockmap, add hash map support")
next prev parent reply other threads:[~2018-05-27 4:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-25 17:37 [bpf-next PATCH] bpf: sockhash fix race with bpf_tcp_close and map delete John Fastabend
2018-05-26 6:07 ` Song Liu
2018-05-26 8:30 ` Daniel Borkmann
2018-05-27 4:36 ` John Fastabend [this message]
2018-05-27 22:36 ` Daniel Borkmann
2018-05-28 15:13 ` John Fastabend
2018-05-28 15:48 ` Daniel Borkmann
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=26e7a154-9d7d-8547-4c39-dd85d72efaa0@gmail.com \
--to=john.fastabend@gmail.com \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=netdev@vger.kernel.org \
/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).