From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Shigeru Yoshida <syoshida@redhat.com>,
syzbot+9ca7a12fd736d93e0232@syzkaller.appspotmail.com,
Hans Verkuil <hverkuil-cisco@xs4all.nl>,
Sasha Levin <sashal@kernel.org>,
hverkuil@xs4all.nl, mchehab@kernel.org,
linux-media@vger.kernel.org
Subject: [PATCH AUTOSEL 4.14 22/23] media: si470x: Fix use-after-free in si470x_int_in_callback()
Date: Sun, 18 Dec 2022 11:21:48 -0500 [thread overview]
Message-ID: <20221218162149.935047-22-sashal@kernel.org> (raw)
In-Reply-To: <20221218162149.935047-1-sashal@kernel.org>
From: Shigeru Yoshida <syoshida@redhat.com>
[ Upstream commit 7d21e0b1b41b21d628bf2afce777727bd4479aa5 ]
syzbot reported use-after-free in si470x_int_in_callback() [1]. This
indicates that urb->context, which contains struct si470x_device
object, is freed when si470x_int_in_callback() is called.
The cause of this issue is that si470x_int_in_callback() is called for
freed urb.
si470x_usb_driver_probe() calls si470x_start_usb(), which then calls
usb_submit_urb() and si470x_start(). If si470x_start_usb() fails,
si470x_usb_driver_probe() doesn't kill urb, but it just frees struct
si470x_device object, as depicted below:
si470x_usb_driver_probe()
...
si470x_start_usb()
...
usb_submit_urb()
retval = si470x_start()
return retval
if (retval < 0)
free struct si470x_device object, but don't kill urb
This patch fixes this issue by killing urb when si470x_start_usb()
fails and urb is submitted. If si470x_start_usb() fails and urb is
not submitted, i.e. submitting usb fails, it just frees struct
si470x_device object.
Reported-by: syzbot+9ca7a12fd736d93e0232@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?id=94ed6dddd5a55e90fd4bab942aa4bb297741d977 [1]
Signed-off-by: Shigeru Yoshida <syoshida@redhat.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/media/radio/si470x/radio-si470x-usb.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/media/radio/si470x/radio-si470x-usb.c b/drivers/media/radio/si470x/radio-si470x-usb.c
index 95581a847619..5710f362a26d 100644
--- a/drivers/media/radio/si470x/radio-si470x-usb.c
+++ b/drivers/media/radio/si470x/radio-si470x-usb.c
@@ -736,8 +736,10 @@ static int si470x_usb_driver_probe(struct usb_interface *intf,
/* start radio */
retval = si470x_start_usb(radio);
- if (retval < 0)
+ if (retval < 0 && !radio->int_in_running)
goto err_buf;
+ else if (retval < 0) /* in case of radio->int_in_running == 1 */
+ goto err_all;
/* set initial frequency */
si470x_set_freq(radio, 87.5 * FREQ_MUL); /* available in all regions */
--
2.35.1
next prev parent reply other threads:[~2022-12-18 17:08 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-18 16:21 [PATCH AUTOSEL 4.14 01/23] wifi: ath9k: verify the expected usb_endpoints are present Sasha Levin
2022-12-18 16:21 ` [PATCH AUTOSEL 4.14 02/23] wifi: ar5523: Fix use-after-free on ar5523_cmd() timed out Sasha Levin
2022-12-18 16:21 ` [PATCH AUTOSEL 4.14 03/23] ASoC: codecs: rt298: Add quirk for KBL-R RVP platform Sasha Levin
2022-12-18 16:21 ` [PATCH AUTOSEL 4.14 04/23] ipmi: fix memleak when unload ipmi driver Sasha Levin
2022-12-18 16:21 ` [PATCH AUTOSEL 4.14 05/23] bpf: make sure skb->len != 0 when redirecting to a tunneling device Sasha Levin
2022-12-18 16:21 ` [PATCH AUTOSEL 4.14 06/23] net: ethernet: ti: Fix return type of netcp_ndo_start_xmit() Sasha Levin
2022-12-18 16:21 ` [PATCH AUTOSEL 4.14 07/23] hamradio: baycom_epp: Fix return type of baycom_send_packet() Sasha Levin
2022-12-18 16:21 ` [PATCH AUTOSEL 4.14 08/23] wifi: brcmfmac: Fix potential shift-out-of-bounds in brcmf_fw_alloc_request() Sasha Levin
2022-12-18 16:21 ` [PATCH AUTOSEL 4.14 09/23] igb: Do not free q_vector unless new one was allocated Sasha Levin
2022-12-18 16:21 ` [PATCH AUTOSEL 4.14 10/23] s390/ctcm: Fix return type of ctc{mp,}m_tx() Sasha Levin
2022-12-18 16:21 ` [PATCH AUTOSEL 4.14 11/23] s390/netiucv: Fix return type of netiucv_tx() Sasha Levin
2022-12-18 16:21 ` [PATCH AUTOSEL 4.14 12/23] s390/lcs: Fix return type of lcs_start_xmit() Sasha Levin
2022-12-18 16:21 ` [PATCH AUTOSEL 4.14 13/23] drm/sti: Use drm_mode_copy() Sasha Levin
2022-12-18 16:21 ` [PATCH AUTOSEL 4.14 14/23] md/raid1: stop mdx_raid1 thread when raid1 array run failed Sasha Levin
2022-12-18 16:21 ` [PATCH AUTOSEL 4.14 15/23] mrp: introduce active flags to prevent UAF when applicant uninit Sasha Levin
2022-12-18 16:21 ` [PATCH AUTOSEL 4.14 16/23] ppp: associate skb with a device at tx Sasha Levin
2022-12-18 16:21 ` [PATCH AUTOSEL 4.14 17/23] media: dvb-frontends: fix leak of memory fw Sasha Levin
2022-12-18 16:21 ` [PATCH AUTOSEL 4.14 18/23] media: dvbdev: adopts refcnt to avoid UAF Sasha Levin
2022-12-18 16:21 ` [PATCH AUTOSEL 4.14 19/23] media: dvb-usb: fix memory leak in dvb_usb_adapter_init() Sasha Levin
2022-12-18 16:21 ` [PATCH AUTOSEL 4.14 20/23] blk-mq: fix possible memleak when register 'hctx' failed Sasha Levin
2022-12-18 16:21 ` [PATCH AUTOSEL 4.14 21/23] mmc: f-sdh30: Add quirks for broken timeout clock capability Sasha Levin
2022-12-18 16:21 ` Sasha Levin [this message]
2022-12-18 16:21 ` [PATCH AUTOSEL 4.14 23/23] clk: st: Fix memory leak in st_of_quadfs_setup() Sasha Levin
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=20221218162149.935047-22-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=hverkuil-cisco@xs4all.nl \
--cc=hverkuil@xs4all.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=stable@vger.kernel.org \
--cc=syoshida@redhat.com \
--cc=syzbot+9ca7a12fd736d93e0232@syzkaller.appspotmail.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