Development discussion of WireGuard
 help / color / mirror / Atom feed
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: edumazet@google.com,
	syzbot <syzbot+c2775460db0e1c70018e@syzkaller.appspotmail.com>,
	netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com,
	davem@davemloft.net, linux-kernel@vger.kernel.org,
	pabeni@redhat.com, wireguard@lists.zx2c4.com, jann@thejh.net
Subject: Re: [syzbot] [wireguard?] KASAN: slab-use-after-free Write in enqueue_timer
Date: Tue, 23 May 2023 18:14:18 +0200	[thread overview]
Message-ID: <ZGzmWtd7itw6oFsI@zx2c4.com> (raw)
In-Reply-To: <20230523090512.19ca60b6@kernel.org>

On Tue, May 23, 2023 at 09:05:12AM -0700, Jakub Kicinski wrote:
> On Tue, 23 May 2023 17:46:20 +0200 Jason A. Donenfeld wrote:
> > > Freed by task 41:
> > >  __kmem_cache_free+0x264/0x3c0 mm/slub.c:3799
> > >  device_release+0x95/0x1c0
> > >  kobject_cleanup lib/kobject.c:683 [inline]
> > >  kobject_release lib/kobject.c:714 [inline]
> > >  kref_put include/linux/kref.h:65 [inline]
> > >  kobject_put+0x228/0x470 lib/kobject.c:731
> > >  netdev_run_todo+0xe5a/0xf50 net/core/dev.c:10400  
> > 
> > So that means the memory in question is actually the one that's
> > allocated and freed by the networking stack. Specifically, dev.c:10626
> > is allocating a struct net_device with a trailing struct wg_device (its
> > priv_data). However, wg_device does not have any struct timer_lists in
> > it, and I don't see how net_device's watchdog_timer would be related to
> > the stacktrace which is clearly operating over a wg_peer timer.
> > 
> > So what on earth is going on here?
> 
> Your timer had the pleasure of getting queued _after_ a dead watchdog
> timer, no? IOW it tries to update the ->next pointer of a queued
> watchdog timer. 

Ahh, you're right! Specifically,

> hlist_add_head include/linux/list.h:945 [inline]
> enqueue_timer+0xad/0x560 kernel/time/timer.c:605

The write on line 945 refers to the side of the timer base, not the
peer's timer_list being queued. So indeed, the wireguard netdev is still
alive at this point, but it's being queued to a timer in a different
netdev that's already been freed (whether watchdog or otherwise in some
privdata). So, IOW, not a wireguard bug, right?

Jason

  parent reply	other threads:[~2023-05-23 16:24 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-30 18:01 syzbot
2023-05-23 15:46 ` Jason A. Donenfeld
2023-05-23 16:05   ` Jakub Kicinski
2023-05-23 16:12     ` Eric Dumazet
2023-05-23 16:41       ` Jakub Kicinski
2023-05-23 16:42         ` Jason A. Donenfeld
2023-05-23 16:47           ` Jakub Kicinski
2023-05-23 17:01             ` Jason A. Donenfeld
2023-05-23 17:05               ` Eric Dumazet
2023-05-23 17:07                 ` Eric Dumazet
2023-05-24  8:24                   ` Dmitry Vyukov
2023-05-24 15:33                     ` Jakub Kicinski
2023-05-24 15:39                       ` Jakub Kicinski
2023-05-23 16:14     ` Jason A. Donenfeld [this message]
2023-05-23 16:46       ` Jakub Kicinski
2023-05-23 16:47         ` Jason A. Donenfeld
2023-05-23 17:16           ` Jason A. Donenfeld
2023-05-23 17:28             ` Jason A. Donenfeld

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=ZGzmWtd7itw6oFsI@zx2c4.com \
    --to=jason@zx2c4.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jann@thejh.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=syzbot+c2775460db0e1c70018e@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=wireguard@lists.zx2c4.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).