All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Skripkin <paskripkin@gmail.com>
To: Dongliang Mu <mudongliangabcd@gmail.com>
Cc: syzbot <syzbot+5872a520e0ce0a7c7230@syzkaller.appspotmail.com>,
	Larry.Finger@lwfinger.net, florian.c.schilhabel@googlemail.com,
	Greg KH <gregkh@linuxfoundation.org>,
	hridayhegde1999@gmail.com,
	linux-kernel <linux-kernel@vger.kernel.org>,
	linux-staging@lists.linux.dev, rkovhaev@gmail.com,
	straube.linux@gmail.com,
	syzkaller-bugs <syzkaller-bugs@googlegroups.com>
Subject: Re: [syzbot] KASAN: use-after-free Read in r871xu_dev_remove
Date: Tue, 13 Jul 2021 12:19:08 +0300	[thread overview]
Message-ID: <20210713121908.181cb183@gmail.com> (raw)
In-Reply-To: <CAD-N9QU3jHw_gOiwduF+eATJ_sxcUcMiiBDESBYmZ8NdGH5RCQ@mail.gmail.com>

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

On Tue, 13 Jul 2021 17:04:28 +0800
Dongliang Mu <mudongliangabcd@gmail.com> wrote:

> On Tue, Jul 13, 2021 at 4:55 PM Pavel Skripkin <paskripkin@gmail.com>
> wrote:
> >
> > On Mon, 12 Jul 2021 20:14:24 -0700
> > syzbot <syzbot+5872a520e0ce0a7c7230@syzkaller.appspotmail.com>
> > wrote:
> >
> > > Hello,
> > >
> > > syzbot found the following issue on:
> > >
> > > HEAD commit:    92510a7f Add linux-next specific files for
> > > 20210709 git tree:       linux-next
> > > console output:
> > > https://syzkaller.appspot.com/x/log.txt?x=16c50180300000 kernel
> > > config:
> > > https://syzkaller.appspot.com/x/.config?x=505de2716f052686
> > > dashboard link:
> > > https://syzkaller.appspot.com/bug?extid=5872a520e0ce0a7c7230 syz
> > > repro: https://syzkaller.appspot.com/x/repro.syz?x=1639a73c300000
> > > C reproducer:
> > > https://syzkaller.appspot.com/x/repro.c?x=15fcd5e4300000
> > >
> > > IMPORTANT: if you fix the issue, please add the following tag to
> > > the commit: Reported-by:
> > > syzbot+5872a520e0ce0a7c7230@syzkaller.appspotmail.com
> > >
> >
> > Hmm, bisection is wrong this time. It should be
> > e02a3b945816 ("staging: rtl8712: fix memory leak in
> > rtl871x_load_fw_cb")
> 
> Hi Paval,
> 
    ^^^^^
    Pavel :)

> can you share more details about why the patch e02a3b945816 causes
> this UAF problem?
> 

I am not sure, but I think, that free_netdev() call rigth after
complete() can cause use-after-free bug in wait_for_completion() since
rtl8712_fw_ready is allocated as netdev private data.

I guess, schedule() call after complete() can help here.


BTW, I send wrong patch in previous email: typo in schedule() :)

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




> >
> > #syz test:
> > git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
> > master
> >
> >
> > I guess, this should work
> >
> >
> > With regards,
> > Pavel Skripkin
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "syzkaller-bugs" group. To unsubscribe from this group and
> > stop receiving emails from it, send an email to
> > syzkaller-bugs+unsubscribe@googlegroups.com. To view this
> > discussion on the web visit
> > https://groups.google.com/d/msgid/syzkaller-bugs/20210713115546.34c99ea8%40gmail.com.




With regards,
Pavel Skripkin

[-- Attachment #2: 0001-staging-rtl8712-fix-UAF-in-r871xu_dev_remove.patch --]
[-- Type: text/x-patch, Size: 902 bytes --]

From 4c25accd0fc806687142aadeaa5b19805289ac74 Mon Sep 17 00:00:00 2001
From: Pavel Skripkin <paskripkin@gmail.com>
Date: Tue, 13 Jul 2021 11:52:17 +0300
Subject: [PATCH] staging: rtl8712: fix UAF in r871xu_dev_remove

/* .... */

Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
---
 drivers/staging/rtl8712/hal_init.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c
index 22974277afa0..e81c66cc8580 100644
--- a/drivers/staging/rtl8712/hal_init.c
+++ b/drivers/staging/rtl8712/hal_init.c
@@ -43,6 +43,7 @@ static void rtl871x_load_fw_cb(const struct firmware *firmware, void *context)
 		r8712_free_drv_sw(adapter);
 		adapter->dvobj_deinit(adapter);
 		complete(&adapter->rtl8712_fw_ready);
+		schedule();				/* to not trigger UAF in wait_for_completion() */
 		free_netdev(adapter->pnetdev);
 		return;
 	}
-- 
2.32.0


  reply	other threads:[~2021-07-13  9:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-13  3:14 [syzbot] KASAN: use-after-free Read in r871xu_dev_remove syzbot
2021-07-13  8:55 ` Pavel Skripkin
2021-07-13  9:04   ` Dongliang Mu
2021-07-13  9:19     ` Pavel Skripkin [this message]
2021-07-13 11:18       ` syzbot
2021-07-13 11:07   ` syzbot
2021-07-21 10:01 ` Pavel Skripkin
2021-07-21 17:12   ` 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=20210713121908.181cb183@gmail.com \
    --to=paskripkin@gmail.com \
    --cc=Larry.Finger@lwfinger.net \
    --cc=florian.c.schilhabel@googlemail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hridayhegde1999@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=mudongliangabcd@gmail.com \
    --cc=rkovhaev@gmail.com \
    --cc=straube.linux@gmail.com \
    --cc=syzbot+5872a520e0ce0a7c7230@syzkaller.appspotmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.