Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Pavel Skripkin <paskripkin@gmail.com>
To: syzbot <syzbot+abd2e0dafb481b621869@syzkaller.appspotmail.com>,
	krzysztof.kozlowski@canonical.com, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] INFO: task hung in port100_probe
Date: Wed, 9 Mar 2022 22:33:54 +0300	[thread overview]
Message-ID: <d9addbc6-b4bd-289e-9c57-87dc9034f6a2@gmail.com> (raw)
In-Reply-To: <000000000000c644cd05c55ca652@google.com>

[-- Attachment #1: Type: text/plain, Size: 783 bytes --]

On 6/22/21 18:43, syzbot wrote:
> Hello,
> 
> syzbot found the following issue on:
> 
> HEAD commit:    fd0aa1a4 Merge tag 'for-linus' of git://git.kernel.org/pub..
> git tree:       upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=13e1500c300000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=7ca96a2d153c74b0
> dashboard link: https://syzkaller.appspot.com/bug?extid=abd2e0dafb481b621869
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=1792e284300000
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=13ad9d48300000
> 


Hm, I can't reproduce this issue on top of my tree. Let's test my latest 
port100 patch

#syz test
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master




With regards,
Pavel Skripkin

[-- Attachment #2: ph --]
[-- Type: text/plain, Size: 3056 bytes --]

commit 131f7ebb9a3d8d271e3b384eefd69b94c0cfc784
Author: Pavel Skripkin <paskripkin@gmail.com>
Date:   Tue Mar 8 21:42:00 2022 +0300

    NFC: port100: fix use-after-free in port100_send_complete
    
    Syzbot reported UAF in port100_send_complete(). The root case is in
    missing usb_kill_urb() calls on error handling path of ->probe function.
    
    port100_send_complete() accesses devm allocated memory which will be
    freed on probe failure. We should kill this urbs before returning an
    error from probe function to prevent reported use-after-free
    
    Fail log:
    
    BUG: KASAN: use-after-free in port100_send_complete+0x16e/0x1a0 drivers/nfc/port100.c:935
    Read of size 1 at addr ffff88801bb59540 by task ksoftirqd/2/26
    ...
    Call Trace:
     <TASK>
     __dump_stack lib/dump_stack.c:88 [inline]
     dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
     print_address_description.constprop.0.cold+0x8d/0x303 mm/kasan/report.c:255
     __kasan_report mm/kasan/report.c:442 [inline]
     kasan_report.cold+0x83/0xdf mm/kasan/report.c:459
     port100_send_complete+0x16e/0x1a0 drivers/nfc/port100.c:935
     __usb_hcd_giveback_urb+0x2b0/0x5c0 drivers/usb/core/hcd.c:1670
    
    ...
    
    Allocated by task 1255:
     kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
     kasan_set_track mm/kasan/common.c:45 [inline]
     set_alloc_info mm/kasan/common.c:436 [inline]
     ____kasan_kmalloc mm/kasan/common.c:515 [inline]
     ____kasan_kmalloc mm/kasan/common.c:474 [inline]
     __kasan_kmalloc+0xa6/0xd0 mm/kasan/common.c:524
     alloc_dr drivers/base/devres.c:116 [inline]
     devm_kmalloc+0x96/0x1d0 drivers/base/devres.c:823
     devm_kzalloc include/linux/device.h:209 [inline]
     port100_probe+0x8a/0x1320 drivers/nfc/port100.c:1502
    
    Freed by task 1255:
     kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
     kasan_set_track+0x21/0x30 mm/kasan/common.c:45
     kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370
     ____kasan_slab_free mm/kasan/common.c:366 [inline]
     ____kasan_slab_free+0xff/0x140 mm/kasan/common.c:328
     kasan_slab_free include/linux/kasan.h:236 [inline]
     __cache_free mm/slab.c:3437 [inline]
     kfree+0xf8/0x2b0 mm/slab.c:3794
     release_nodes+0x112/0x1a0 drivers/base/devres.c:501
     devres_release_all+0x114/0x190 drivers/base/devres.c:530
     really_probe+0x626/0xcc0 drivers/base/dd.c:670
    
    Reported-and-tested-by: syzbot+16bcb127fb73baeecb14@syzkaller.appspotmail.com
    Fixes: 0347a6ab300a ("NFC: port100: Commands mechanism implementation")
    Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>

diff --git a/drivers/nfc/port100.c b/drivers/nfc/port100.c
index d7db1a0e6be1..00d8ea6dcb5d 100644
--- a/drivers/nfc/port100.c
+++ b/drivers/nfc/port100.c
@@ -1612,7 +1612,9 @@ static int port100_probe(struct usb_interface *interface,
 	nfc_digital_free_device(dev->nfc_digital_dev);
 
 error:
+	usb_kill_urb(dev->in_urb);
 	usb_free_urb(dev->in_urb);
+	usb_kill_urb(dev->out_urb);
 	usb_free_urb(dev->out_urb);
 	usb_put_dev(dev->udev);
 

  parent reply	other threads:[~2022-03-09 19:34 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-22 15:43 syzbot
2021-06-22 16:07 ` Pavel Skripkin
2021-06-22 16:21   ` syzbot
2021-07-22 14:20 ` Krzysztof Kozlowski
2021-07-22 14:23   ` Krzysztof Kozlowski
2021-07-22 14:47   ` Alan Stern
2021-07-23  9:05     ` Krzysztof Kozlowski
2021-07-23 13:07       ` Alan Stern
2021-10-20 20:56     ` Krzysztof Kozlowski
2021-10-20 22:05       ` Alan Stern
2021-10-25 14:57         ` Krzysztof Kozlowski
2021-10-25 16:22           ` Alan Stern
2021-10-25 17:13             ` Krzysztof Kozlowski
2021-10-25 18:54               ` Alan Stern
2022-03-09 19:33 ` Pavel Skripkin [this message]
2022-03-09 19:56   ` syzbot
     [not found] <20220310084247.1148-1-hdanton@sina.com>
2022-03-10 14:22 ` syzbot
     [not found] ` <20220311053751.1226-1-hdanton@sina.com>
2022-03-11 19:17   ` Pavel Skripkin
2022-03-11 19:18     ` syzbot
2022-03-11 19:19       ` Pavel Skripkin
2022-03-11 19:32         ` syzbot
     [not found]   ` <20220312005624.1310-1-hdanton@sina.com>
2022-03-12 10:36     ` Pavel Skripkin
     [not found]     ` <20220312115854.1399-1-hdanton@sina.com>
2022-03-12 12:44       ` Pavel Skripkin

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=d9addbc6-b4bd-289e-9c57-87dc9034f6a2@gmail.com \
    --to=paskripkin@gmail.com \
    --cc=krzysztof.kozlowski@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=syzbot+abd2e0dafb481b621869@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --subject='Re: [syzbot] INFO: task hung in port100_probe' \
    /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).