Skip to contentSkip to conversation

media: dvb-core: pin frontend device through release

PATCH New Yousef Alhouseen 1 participant 1 message Jun 28

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: dvb-core: pin frontend device through release

dvb_generic_release() drops the reference held by the open file. Device unregistration may already have dropped the registration reference, in which case the call frees dvbdev. dvb_frontend_release() nevertheless continues to inspect its user count, wait queue, media entity and private frontend after that call, causing a use-after-free.

Take a temporary device reference around the generic release and the remaining frontend shutdown work.

Fixes 0fc044b2b5e2 ("media: dvbdev: adopts refcnt to avoid UAF")
Reported-by [email protected]
---
 drivers/media/dvb-core/dvb_frontend.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/media/dvb-core/dvb_frontend.c +2 -0
index 7aebaef18191..1276fe704675 100644
@@ -2912,6 +2912,7 @@ static int dvb_frontend_release(struct inode *inode, struct file *file)
 		mb();
 	}
 
+	dvb_device_get(dvbdev);
 	ret = dvb_generic_release(inode, file);
 
 	if (dvbdev->users == -1) {
@@ -2933,6 +2934,7 @@ static int dvb_frontend_release(struct inode *inode, struct file *file)
 	}
 
 	dvb_frontend_put(fe);
+	dvb_device_put(dvbdev);
 
 	return ret;
 }
Signature · 1 line
2.54.0