Skip to content

Commit 204f212

Browse files
committed
media: uvcvideo: Only save async fh if success
jira VULN-53462 jira VULN-53461 cve-pre CVE-2024-58002 commit-author Ricardo Ribalda <ribalda@chromium.org> commit d9fecd0 Now we keep a reference to the active fh for any call to uvc_ctrl_set, regardless if it is an actual set or if it is a just a try or if the device refused the operation. We should only keep the file handle if the device actually accepted applying the operation. Cc: stable@vger.kernel.org Fixes: e5225c8 ("media: uvcvideo: Send a control event when a Control Change interrupt arrives") Suggested-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> Link: https://lore.kernel.org/r/20241203-uvc-fix-async-v6-1-26c867231118@chromium.org Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> (cherry picked from commit d9fecd0) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 181b6df commit 204f212

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

drivers/media/usb/uvc/uvc_ctrl.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,7 +1764,10 @@ int uvc_ctrl_begin(struct uvc_video_chain *chain)
17641764
}
17651765

17661766
static int uvc_ctrl_commit_entity(struct uvc_device *dev,
1767-
struct uvc_entity *entity, int rollback, struct uvc_control **err_ctrl)
1767+
struct uvc_fh *handle,
1768+
struct uvc_entity *entity,
1769+
int rollback,
1770+
struct uvc_control **err_ctrl)
17681771
{
17691772
struct uvc_control *ctrl;
17701773
unsigned int i;
@@ -1812,6 +1815,10 @@ static int uvc_ctrl_commit_entity(struct uvc_device *dev,
18121815
*err_ctrl = ctrl;
18131816
return ret;
18141817
}
1818+
1819+
if (!rollback && handle &&
1820+
ctrl->info.flags & UVC_CTRL_FLAG_ASYNCHRONOUS)
1821+
ctrl->handle = handle;
18151822
}
18161823

18171824
return 0;
@@ -1848,8 +1855,8 @@ int __uvc_ctrl_commit(struct uvc_fh *handle, int rollback,
18481855

18491856
/* Find the control. */
18501857
list_for_each_entry(entity, &chain->entities, chain) {
1851-
ret = uvc_ctrl_commit_entity(chain->dev, entity, rollback,
1852-
&err_ctrl);
1858+
ret = uvc_ctrl_commit_entity(chain->dev, handle, entity,
1859+
rollback, &err_ctrl);
18531860
if (ret < 0) {
18541861
if (ctrls)
18551862
ctrls->error_idx =
@@ -1999,9 +2006,6 @@ int uvc_ctrl_set(struct uvc_fh *handle,
19992006
mapping->set(mapping, value,
20002007
uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT));
20012008

2002-
if (ctrl->info.flags & UVC_CTRL_FLAG_ASYNCHRONOUS)
2003-
ctrl->handle = handle;
2004-
20052009
ctrl->dirty = 1;
20062010
ctrl->modified = 1;
20072011
return 0;
@@ -2323,7 +2327,7 @@ int uvc_ctrl_restore_values(struct uvc_device *dev)
23232327
ctrl->dirty = 1;
23242328
}
23252329

2326-
ret = uvc_ctrl_commit_entity(dev, entity, 0, NULL);
2330+
ret = uvc_ctrl_commit_entity(dev, NULL, entity, 0, NULL);
23272331
if (ret < 0)
23282332
return ret;
23292333
}

0 commit comments

Comments
 (0)