summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRicardo B. Marliere <ricardo@marliere.net>2023-10-13 01:09:12 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-01-25 14:33:35 -0800
commitec36c134dd020d28e312c2f1766f85525e747aab (patch)
treecef789e5f9a2d341e7249e7ca508addf4ab5fd6b
parentef87ffe5e8093ea540803811b1496238d778069c (diff)
downloadlinux-stable-ec36c134dd020d28e312c2f1766f85525e747aab.tar.gz
linux-stable-ec36c134dd020d28e312c2f1766f85525e747aab.tar.bz2
linux-stable-ec36c134dd020d28e312c2f1766f85525e747aab.zip
media: pvrusb2: fix use after free on context disconnection
[ Upstream commit ded85b0c0edd8f45fec88783d7555a5b982449c1 ] Upon module load, a kthread is created targeting the pvr2_context_thread_func function, which may call pvr2_context_destroy and thus call kfree() on the context object. However, that might happen before the usb hub_event handler is able to notify the driver. This patch adds a sanity check before the invalid read reported by syzbot, within the context disconnection call stack. Reported-and-tested-by: syzbot+621409285c4156a009b3@syzkaller.appspotmail.com Closes: https://lore.kernel.org/all/000000000000a02a4205fff8eb92@google.com/ Fixes: e5be15c63804 ("V4L/DVB (7711): pvrusb2: Fix race on module unload") Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net> Acked-by: Mike Isely <isely@pobox.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-context.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-context.c b/drivers/media/usb/pvrusb2/pvrusb2-context.c
index d9e8481e9e28..9236463ba269 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-context.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-context.c
@@ -277,7 +277,8 @@ void pvr2_context_disconnect(struct pvr2_context *mp)
{
pvr2_hdw_disconnect(mp->hdw);
mp->disconnect_flag = !0;
- pvr2_context_notify(mp);
+ if (!pvr2_context_shutok())
+ pvr2_context_notify(mp);
}