From: Phong Tran <tranmanphong@gmail.com>
To: syzbot+495dab1f175edc9c2f13@syzkaller.appspotmail.com
Cc: 2pi@mok.nu, alex.theissen@me.com, andreyknvl@google.com,
gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
linux-usb@vger.kernel.org, syzkaller-bugs@googlegroups.com,
linux-kernel-mentees@lists.linuxfoundation.org,
Phong Tran <tranmanphong@gmail.com>
Subject: [PATCH] usb: appledisplay: fix use-after-free in bl_get_brightness
Date: Wed, 6 Nov 2019 06:36:52 +0700 [thread overview]
Message-ID: <20191105233652.21033-1-tranmanphong@gmail.com> (raw)
In-Reply-To: <00000000000042d60805933945b5@google.com>
In context of USB disconnect, the delaywork trigger and calling
appledisplay_bl_get_brightness() and the msgdata was freed.
add the checking return value of usb_control_msg() and only update the
data while the retval is valid.
Reported-by: syzbot+495dab1f175edc9c2f13@syzkaller.appspotmail.com
Reported-and-tested-by:
syzbot+495dab1f175edc9c2f13@syzkaller.appspotmail.com
https://groups.google.com/d/msg/syzkaller-bugs/dRmkh2UYusY/l2a6Mg3FAQAJ
Signed-off-by: Phong Tran <tranmanphong@gmail.com>
---
drivers/usb/misc/appledisplay.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
index ac92725458b5..3e3dfa5a3954 100644
--- a/drivers/usb/misc/appledisplay.c
+++ b/drivers/usb/misc/appledisplay.c
@@ -164,7 +164,8 @@ static int appledisplay_bl_get_brightness(struct backlight_device *bd)
0,
pdata->msgdata, 2,
ACD_USB_TIMEOUT);
- brightness = pdata->msgdata[1];
+ if (retval >= 0)
+ brightness = pdata->msgdata[1];
mutex_unlock(&pdata->sysfslock);
if (retval < 0)
--
2.20.1
next prev parent reply other threads:[~2019-11-05 23:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-23 14:31 KASAN: use-after-free Read in appledisplay_bl_get_brightness syzbot
2019-09-23 14:53 ` Alexander Theißen
2019-11-05 23:36 ` Phong Tran [this message]
2019-11-06 11:42 ` [PATCH] usb: appledisplay: fix use-after-free in bl_get_brightness Oliver Neukum
2019-11-06 12:26 ` KASAN: use-after-free Read in appledisplay_bl_get_brightness syzbot
2019-11-06 14:22 ` [PATCH] usb: appledisplay: fix use-after-free in bl_get_brightness Phong Tran
2019-11-07 8:50 ` Oliver Neukum
2019-11-06 12:10 ` Andrey Konovalov
2019-11-06 12:11 ` Andrey Konovalov
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=20191105233652.21033-1-tranmanphong@gmail.com \
--to=tranmanphong@gmail.com \
--cc=2pi@mok.nu \
--cc=alex.theissen@me.com \
--cc=andreyknvl@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=syzbot+495dab1f175edc9c2f13@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 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).