Skip to contentSkip to conversation

media: dvb-core: fix use-after-free in dvb_frontend_open()

PATCH Superseded Yun Zhou 1 participant 2 messages May 22 – May 25 1 message not in the archive Media (V4L/DVB)

lore
Share & tools
lore

Yun Zhou

author
#0 lore raw

PATCH v3 1/1 media: dvb-core: fix use-after-free in dvb_frontend_open()

dvb_frontend_open() calls dvb_generic_release() in its error path after dvb_generic_open() succeeds. dvb_generic_release() drops the device reference via dvb_device_put(), and then dvb_device_open() drops it again in its error handling, causing a use-after-free and refcount underflow.

Fix this by incrementing the refcount before dvb_generic_release() in the error path, so that the put inside dvb_generic_release() is balanced and dvb_device_open() remains the sole effective put on open failure.

Reported-by [email protected]
Fixes 0fc044b2b5e2 ("media: dvbdev: adopts refcnt to avoid UAF")

---
v3:
- Simplify fix: increment refcount before dvb_generic_release() instead of introducing __dvb_generic_release()

v2:
- Fix Fixes tag commit title
- Add Closes: link after Reported-by
- Cc [email protected]

 drivers/media/dvb-core/dvb_frontend.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/dvb-core/dvb_frontend.c +1 -0
index d082b6c57c76..608525d08277 100644
@@ -2887,6 +2887,7 @@ static int dvb_frontend_open(struct inode *inode, struct file *file)
 	mutex_unlock(&fe->dvb->mdev_lock);
 err2:
 #endif
+	dvb_device_get(dvbdev);
 	dvb_generic_release(inode, file);
 err1:
 	if (dvbdev->users == -1 && fe->ops.ts_bus_ctrl)
Signature · 1 line
2.43.0

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#2 lore raw

It seems that these two failed test cases are unrelated to my patch.

Quoted 32 lines · Patchwork Integration

CAUTION: This email comes from a non Wind River email account!
Do not click links or open attachments unless you recognize the sender and know the content is safe.

Dear Yun Zhou:

Thanks for your patches! Unfortunately the Media CI robot detected some issues:

# Test virtme32:test-virtme
Error running test. Final Summary not found

Please fix your series, and upload a new version. If you have a patchwork account, do not forget to mark the current series as Superseded.

For more details, check the full report at:
https://linux-media.pages.freedesktop.org/-/users/patchwork/-/jobs/100505107/artifacts/report.htm .

Best regards, and Happy Hacking!
Media CI robot on behalf of the linux-media community.

---
Check the latest rules for contributing your patches at:
https://docs.kernel.org/driver-api/media/maintainer-entry-profile.html

If you believe that the CI is wrong, kindly open an issue at
https://gitlab.freedesktop.org/linux-media/media-ci/-/issues or reply-all to this message.