media: dvb-core: avoid dropping device ref on frontend open failure
Subsystems (2)
PATCH 1/1 media: dvb-core: avoid dropping device ref on frontend open failure
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 [email protected]
Signed-off-by Yousef Alhouseen <[email protected]>
--- drivers/media/dvb-core/dvb_frontend.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/dvb-core/dvb_frontend.c +2 -1
@@ -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 );
Signature · 1 line
2.54.0