* [PATCH] media: dvb-core: avoid dropping device ref on frontend open failure
@ 2026-06-28 9:18 Yousef Alhouseen
2026-12-02 11:09 ` Krystian Kaniewski
0 siblings, 1 reply; 2+ messages in thread
From: Yousef Alhouseen @ 2026-06-28 9:18 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: linux-media, linux-kernel, stable, syzbot+40339ea82afa8184ad5d,
Yousef Alhouseen
dvb_device_open() takes a device reference before calling the frontend
open callback and drops that reference itself if the callback fails.
However, the frontend error path calls dvb_generic_release(), which drops
the same reference while merely trying to undo the user counters changed
by dvb_generic_open(). A concurrent device unregister can leave this as
the final reference, so the subsequent dvbdev->users access is a
use-after-free. The outer open path then also performs a second put.
Restore the writer and user counters directly. The reference remains
owned by dvb_device_open(), which will release it after the callback
returns the error.
Fixes: 0fc044b2b5e2 ("media: dvbdev: adopts refcnt to avoid UAF")
Reported-by: syzbot+40339ea82afa8184ad5d@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=40339ea82afa8184ad5d
Cc: stable@vger.kernel.org
Signed-off-by: Yousef Alhouseen <alhouseenyousef@gmail.com>
---
drivers/media/dvb-core/dvb_frontend.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
index d082b6c57c76..7aebaef18191 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -2887,7 +2887,8 @@ static int dvb_frontend_open(struct inode *inode, struct file *file)
mutex_unlock(&fe->dvb->mdev_lock);
err2:
#endif
- dvb_generic_release(inode, file);
+ dvbdev->writers++;
+ dvbdev->users++;
err1:
if (dvbdev->users == -1 && fe->ops.ts_bus_ctrl)
fe->ops.ts_bus_ctrl(fe, 0);
--
2.54.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] media: dvb-core: avoid dropping device ref on frontend open failure
2026-06-28 9:18 [PATCH] media: dvb-core: avoid dropping device ref on frontend open failure Yousef Alhouseen
@ 2026-12-02 11:09 ` Krystian Kaniewski
0 siblings, 0 replies; 2+ messages in thread
From: Krystian Kaniewski @ 2026-12-02 11:09 UTC (permalink / raw)
To: Yousef Alhouseen, Mauro Carvalho Chehab
Cc: linux-media, linux-kernel, stable, syzbot+40339ea82afa8184ad5d
On 6/28/26 11:18, Yousef Alhouseen wrote:
Hi Yousef,
On Sun, Jun 28, 2026 at 11:18:44AM +0200, Yousef Alhouseen wrote:
> dvb_device_open() takes a device reference before calling the frontend
> open callback and drops that reference itself if the callback fails.
> However, the frontend error path calls dvb_generic_release(), which drops
> the same reference while merely trying to undo the user counters changed
> by dvb_generic_open().
The same double put is behind the older syzbot report "KASAN:
slab-use-after-free Read in dvb_device_open", open since December
2024. With vidtv it can be hit on demand: open the frontend read-write
while another thread keeps sending the opener a caught signal, so that
dvb_frontend_start() returns -EINTR after dvb_generic_open() has
succeeded. On v7.4-rc4 with the syzbot config, the second such failure
frees the frontend's dvb_device while dvb_minors[] still points to it,
and the next open gives exactly the syzbot report. Failing the
kthread_create_info allocation with fail-nth does the same through
-ENOMEM, and a single failure followed by an unbind of vidtv ends in a
use-after-free in dvb_media_device_free(). The syzbot program itself
gets -EINTR on every frontend open, which is why it hits the bug within
seconds. I can post the small test program if that helps.
With this patch on v7.4-rc4 (it still applies, with an offset after
the dvb_frontend_open() split), 200 interrupted opens and repeated
-ENOMEM failures leave the device usable, a second writer still gets
-EBUSY, unbinding vidtv after a failed open is clean, and the syzbot C
and syz reproducers of the older report run cleanly.
Two remarks on the tags. The double put on this path exists only since
a2dd235df435 ("media: dvbdev: drop refcount on error path in
dvb_device_open()"). With 0fc044b2b5e2 alone the dvb_generic_release()
call balanced the reference taken in dvb_device_open(), so I think the
Fixes tag should name a2dd235df435 instead. And the same patch can
close the older report:
Reported-by: syzbot+1eb177ecc3943b883f0a@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=1eb177ecc3943b883f0a
Tested-by: Krystian Kaniewski <krystianmkaniewski@gmail.com>
Thanks,
--
Krystian Kaniewski
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-02 11:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-28 9:18 [PATCH] media: dvb-core: avoid dropping device ref on frontend open failure Yousef Alhouseen
2026-12-02 11:09 ` Krystian Kaniewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®