linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Hillf Danton <hdanton@sina.com>
Cc: Leon Romanovsky <leon@kernel.org>, SyzScope <syzscope@gmail.com>,
	davem@davemloft.net, johan.hedberg@gmail.com, kuba@kernel.org,
	linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
	Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
	marcel@holtmann.org, netdev@vger.kernel.org,
	syzkaller-bugs@googlegroups.com
Subject: Re: KASAN: use-after-free Read in hci_chan_del
Date: Sun, 6 Jun 2021 11:54:22 +0200	[thread overview]
Message-ID: <YLybTrAP/6kroNJn@kroah.com> (raw)
In-Reply-To: <20210606085004.12212-1-hdanton@sina.com>

On Sun, Jun 06, 2021 at 04:50:04PM +0800, Hillf Danton wrote:
> On 2020-08-02 20:45
> > syzbot found the following issue on:
> > 
> > HEAD commit:    ac3a0c84 Merge git://git.kernel.org/pub/scm/linux/kernel/g..
> > git tree:       upstream
> > console output: https://syzkaller.appspot.com/x/log.txt?x=11b8d570900000
> > kernel config:  https://syzkaller.appspot.com/x/.config?x=e59ee776d5aa8d55
> > dashboard link: https://syzkaller.appspot.com/bug?extid=305a91e025a73e4fd6ce
> > compiler:       clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81)
> > syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=11f7ceea900000
> > C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=17e5de04900000
> > 
> > IMPORTANT: if you fix the issue, please add the following tag to the commit:
> > Reported-by: syzbot+305a91e025a73e4fd6ce@syzkaller.appspotmail.com
> > 
> > IPVS: ftp: loaded support on port[0] = 21
> > ==================================================================
> > BUG: KASAN: use-after-free in hci_chan_del+0x33/0x130 net/bluetooth/hci_conn.c:1707
> > Read of size 8 at addr ffff8880a9591f18 by task syz-executor081/6793
> > 
> > CPU: 0 PID: 6793 Comm: syz-executor081 Not tainted 5.8.0-rc7-syzkaller #0
> > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
> > Call Trace:
> >  __dump_stack lib/dump_stack.c:77 [inline]
> >  dump_stack+0x1f0/0x31e lib/dump_stack.c:118
> >  print_address_description+0x66/0x5a0 mm/kasan/report.c:383
> >  __kasan_report mm/kasan/report.c:513 [inline]
> >  kasan_report+0x132/0x1d0 mm/kasan/report.c:530
> >  hci_chan_del+0x33/0x130 net/bluetooth/hci_conn.c:1707
> >  l2cap_conn_del+0x4c2/0x650 net/bluetooth/l2cap_core.c:1900
> >  hci_disconn_cfm include/net/bluetooth/hci_core.h:1355 [inline]
> >  hci_conn_hash_flush+0x127/0x200 net/bluetooth/hci_conn.c:1536
> >  hci_dev_do_close+0xb7b/0x1040 net/bluetooth/hci_core.c:1761
> >  hci_unregister_dev+0x16d/0x1590 net/bluetooth/hci_core.c:3606
> >  vhci_release+0x73/0xc0 drivers/bluetooth/hci_vhci.c:340
> >  __fput+0x2f0/0x750 fs/file_table.c:281
> >  task_work_run+0x137/0x1c0 kernel/task_work.c:135
> >  exit_task_work include/linux/task_work.h:25 [inline]
> >  do_exit+0x601/0x1f80 kernel/exit.c:805
> >  do_group_exit+0x161/0x2d0 kernel/exit.c:903
> >  __do_sys_exit_group+0x13/0x20 kernel/exit.c:914
> >  __se_sys_exit_group+0x10/0x10 kernel/exit.c:912
> >  __x64_sys_exit_group+0x37/0x40 kernel/exit.c:912
> >  do_syscall_64+0x73/0xe0 arch/x86/entry/common.c:384
> >  entry_SYSCALL_64_after_hwframe+0x44/0xa9
> 
> To fix the uaf reported, add reference count to hci channel to track users.
> Then only channels with zero users will be released.
> 
> It is now only for thoughts.
> 
> +++ x/include/net/bluetooth/hci_core.h
> @@ -704,6 +704,7 @@ struct hci_chan {
>  	struct sk_buff_head data_q;
>  	unsigned int	sent;
>  	__u8		state;
> +	atomic_t ref;

Please no, never use "raw" atomic variables.  Especially for something
like this, use a kref.

thanks,

greg k-h

  parent reply	other threads:[~2021-06-06  9:57 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-02 20:45 KASAN: use-after-free Read in hci_chan_del syzbot
2020-08-03 17:08 ` syzbot
2021-05-04 21:50 ` ETenal
2021-05-06  6:01   ` Dan Carpenter
2021-05-06  6:42     ` SyzScope
2021-06-04  9:48   ` Greg KH
2021-06-04 17:11     ` SyzScope
2021-06-05  7:43       ` Greg KH
2021-06-05 18:12         ` SyzScope
2021-06-06  5:16           ` Greg KH
2021-06-06  5:29             ` Leon Romanovsky
2021-06-06  5:06         ` Leon Romanovsky
     [not found]         ` <20210606085004.12212-1-hdanton@sina.com>
2021-06-06  9:54           ` Greg KH [this message]
     [not found]           ` <20210607074828.3259-1-hdanton@sina.com>
2021-06-07  7:55             ` Greg KH
     [not found]             ` <20210607100201.3345-1-hdanton@sina.com>
2021-06-07 10:31               ` Greg KH
     [not found]               ` <20210608081800.3484-1-hdanton@sina.com>
2021-06-08  8:40                 ` Greg KH
2021-05-28 21:12 ` SyzScope
2021-06-03 18:30   ` SyzScope
2021-06-03 18:36     ` Greg KH
2021-06-07 10:21   ` Jason A. Donenfeld
2021-06-07 10:28     ` Dmitry Vyukov
2021-06-07 11:20     ` Greg KH
2021-06-07 18:26       ` SyzScope
2021-06-08  8:46         ` Greg KH
2021-06-08  8:53     ` Dan Carpenter
2021-06-07 22:25 ` [syzbot] " syzbot

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=YLybTrAP/6kroNJn@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=davem@davemloft.net \
    --cc=hdanton@sina.com \
    --cc=johan.hedberg@gmail.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marcel@holtmann.org \
    --cc=netdev@vger.kernel.org \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=syzscope@gmail.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).