Re: [PATCH] media: dvb-core: avoid dropping device ref on frontend open failure
From: Krystian Kaniewski
Date: Wed Dec 02 2026 - 06:10:07 EST
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@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=1eb177ecc3943b883f0a
Tested-by: Krystian Kaniewski <krystianmkaniewski@xxxxxxxxx>
Thanks,
--
Krystian Kaniewski