From: Jason Gunthorpe <jgg@ziepe.ca>
To: Rustam Kovhaev <rkovhaev@gmail.com>
Cc: dledford@redhat.com, linux-kernel@vger.kernel.org,
linux-rdma@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: KASAN: use-after-free Read in netdevice_event_work_handler
Date: Sun, 2 Aug 2020 19:22:26 -0300 [thread overview]
Message-ID: <20200802222226.GO24045@ziepe.ca> (raw)
In-Reply-To: <20200731211122.GA1728751@thinkpad>
On Fri, Jul 31, 2020 at 02:11:22PM -0700, Rustam Kovhaev wrote:
> IB roce driver receives NETDEV_UNREGISTER event, calls dev_hold() and
> schedules work item to execute, and before wq gets a chance to complete
> it, we return to ip_tunnel.c:274 and call free_netdev(), and then later
> we get UAF when scheduled function references already freed net_device
>
> i added verbose logging to ip_tunnel.c to see pcpu_refcnt:
> + pr_info("about to free_netdev(dev) dev->pcpu_refcnt %d", netdev_refcnt_read(dev));
>
> and got the following:
> [ 410.220127][ T2944] ip_tunnel: about to free_netdev(dev) dev->pcpu_refcnt 8
I think there is a missing call to netdev_wait_allrefs() in the
rollback_registered_many().
The normal success flow has this wait after delivering
NETDEV_UNREGISTER, the error unwind for register_netdevice should as
well.
If the netdevice can progress to free while a dev_hold is active I
think it means dev_hold is functionally useless.
Jason
next prev parent reply other threads:[~2020-08-02 22:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-09 23:54 KASAN: use-after-free Read in netdevice_event_work_handler syzbot
2020-07-22 20:29 ` syzbot
2020-07-31 21:11 ` Rustam Kovhaev
2020-08-01 2:23 ` Rustam Kovhaev
2020-08-02 22:22 ` Jason Gunthorpe [this message]
2020-08-04 20:00 ` Rustam Kovhaev
2020-08-05 15:20 ` Jason Gunthorpe
[not found] <20200731211122.GA1728751 () thinkpad>
2020-08-01 2:06 ` Coiby Xu
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=20200802222226.GO24045@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=dledford@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=rkovhaev@gmail.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).