* [PATCH] media: dvbdev: fix uaf in dvb_remove_device()
@ 2026-08-22 11:22 Jeffin Philip
2026-08-27 3:51 ` Jeffin Philip
0 siblings, 1 reply; 2+ messages in thread
From: Jeffin Philip @ 2026-08-22 11:22 UTC (permalink / raw)
To: mchehab
Cc: kees, hverkuil+cisco, ribalda, sakari.ailus, linma, linux-media,
linux-kernel, syzbot+37578f730d38898f4b74, Jeffin Philip, stable
In dvb_remove_device(), dvb_media_device_free(), device_destroy()
and list_del() all dereference dvbdev regardless of its refcount.
Thus, if refcount for dvbdev is 1, it can be freed and we
operate on freed memory causing a UAF. Fix this by moving
dvb_device_put() at the end of dvb_remove_device() so dvbdev
members can be safely freed and assigned NULL when dvbdev is alive.
Reported-by: syzbot+37578f730d38898f4b74@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=37578f730d38898f4b74
Fixes: 0fc044b2b5e2 ("media: dvbdev: adopts refcnt to avoid UAF")
Cc: stable@vger.kernel.org
Signed-off-by: Jeffin Philip <jeffinphilip14@gmail.com>
---
drivers/media/dvb-core/dvbdev.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index d753d329502a..9aa4b8fd7379 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -598,7 +598,6 @@ void dvb_remove_device(struct dvb_device *dvbdev)
down_write(&minor_rwsem);
dvb_minors[dvbdev->minor] = NULL;
- dvb_device_put(dvbdev);
up_write(&minor_rwsem);
dvb_media_device_free(dvbdev);
@@ -606,6 +605,8 @@ void dvb_remove_device(struct dvb_device *dvbdev)
device_destroy(dvb_class, MKDEV(DVB_MAJOR, dvbdev->minor));
list_del(&dvbdev->list_head);
+
+ dvb_device_put(dvbdev);
}
EXPORT_SYMBOL(dvb_remove_device);
--
2.55.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] media: dvbdev: fix uaf in dvb_remove_device()
2026-08-22 11:22 [PATCH] media: dvbdev: fix uaf in dvb_remove_device() Jeffin Philip
@ 2026-08-27 3:51 ` Jeffin Philip
0 siblings, 0 replies; 2+ messages in thread
From: Jeffin Philip @ 2026-08-27 3:51 UTC (permalink / raw)
To: jeffinphilip14
Cc: hverkuil+cisco, kees, linma, linux-kernel, linux-media, mchehab,
ribalda, sakari.ailus, stable, syzbot+37578f730d38898f4b74
On Sat, 22 Aug 2026 16:52:56 +0530, Jeffin Philip wrote:
>In dvb_remove_device(), dvb_media_device_free(), device_destroy()
>and list_del() all dereference dvbdev regardless of its refcount.
>Thus, if refcount for dvbdev is 1, it can be freed and we
>operate on freed memory causing a UAF. Fix this by moving
>dvb_device_put() at the end of dvb_remove_device() so dvbdev
>members can be safely freed and assigned NULL when dvbdev is alive.
>
>Reported-by: syzbot+37578f730d38898f4b74@syzkaller.appspotmail.com
>Closes: https://syzkaller.appspot.com/bug?extid=37578f730d38898f4b74
>Fixes: 0fc044b2b5e2 ("media: dvbdev: adopts refcnt to avoid UAF")
>Cc: stable@vger.kernel.org
>Signed-off-by: Jeffin Philip <jeffinphilip14@gmail.com>
>---
> drivers/media/dvb-core/dvbdev.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
>diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
>index d753d329502a..9aa4b8fd7379 100644
>--- a/drivers/media/dvb-core/dvbdev.c
>+++ b/drivers/media/dvb-core/dvbdev.c
>@@ -598,7 +598,6 @@ void dvb_remove_device(struct dvb_device *dvbdev)
>
> down_write(&minor_rwsem);
> dvb_minors[dvbdev->minor] = NULL;
>- dvb_device_put(dvbdev);
> up_write(&minor_rwsem);
>
> dvb_media_device_free(dvbdev);
>@@ -606,6 +605,8 @@ void dvb_remove_device(struct dvb_device *dvbdev)
> device_destroy(dvb_class, MKDEV(DVB_MAJOR, dvbdev->minor));
>
> list_del(&dvbdev->list_head);
>+
>+ dvb_device_put(dvbdev);
> }
> EXPORT_SYMBOL(dvb_remove_device);
>
>--
Friendly ping, let me know if you want me to fix anything.
Thanks,
Jeffin.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-27 3:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-22 11:22 [PATCH] media: dvbdev: fix uaf in dvb_remove_device() Jeffin Philip
2026-08-27 3:51 ` Jeffin Philip
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox