media: imon: fix use-after-free in display_close via dev_dbg
PATCH 1/1 media: imon: fix use-after-free in display_close via dev_dbg
ictx->dev is a raw pointer to the usb_interface's embedded device. On disconnect, usb_disconnect() can drop the last reference on the interface and free it while a userspace fd for /dev/lcd0 is still open. When that fd is later closed, display_close() dereferences the now-freed ictx->dev via dev_dbg(), causing a use-after-free.
Remove the dev_dbg() calls that dereference ictx->dev in display_close() and free_imon_context(), rather than taking a reference on the device.
Fixes 21677cfc562a ("V4L/DVB: ir-core: add imon driver")
Reported-by [email protected]
Signed-off-by Deepanshu Kartikey <[email protected]>
---
v3:
- Drop the dev_dbg() calls entirely instead of pinning the device with get_device()/put_device(), per Sean Young.
v2:
- Remove the dev_dbg() in free_imon_context(), as suggested by Sean Young.
--- drivers/media/rc/imon.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/media/rc/imon.c +0 -5
@@ -492,16 +492,12 @@ MODULE_PARM_DESC(pad_thresh, "Threshold at which a pad push registers as an arrostatic void free_imon_context (struct imon_context *ictx) { -struct device *dev = ictx->dev; -usb_free_urb (ictx->tx_urb);WARN_ON (ictx->dev_present_intf0);usb_free_urb (ictx->rx_urb_intf0);WARN_ON (ictx->dev_present_intf1);usb_free_urb (ictx->rx_urb_intf1);kfree_rcu (ictx, rcu); - -dev_dbg (dev,"%s: iMON context freed\n" , __func__); }/*
@@ -577,7 +573,6 @@ static int display_close(struct inode *inode, struct file *file) retval = -EIO ; }else { ictx->display_isopen = false; -dev_dbg (ictx->dev,"display port closed\n" ); }mutex_unlock (&ictx->lock);
Signature · 1 line
2.43.0