Skip to content

Commit 11ce137

Browse files
committed
media: uvcvideo: Only save async fh if success
jira VULN-53466 cve-pre CVE-2024-58002 commit-author Ricardo Ribalda <[email protected]> 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: [email protected] Fixes: e5225c8 ("media: uvcvideo: Send a control event when a Control Change interrupt arrives") Suggested-by: Hans de Goede <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Signed-off-by: Ricardo Ribalda <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Laurent Pinchart <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]> (cherry picked from commit d9fecd0) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 68eef65 commit 11ce137

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
@@ -1606,7 +1606,10 @@ int uvc_ctrl_begin(struct uvc_video_chain *chain)
16061606
}
16071607

16081608
static int uvc_ctrl_commit_entity(struct uvc_device *dev,
1609-
struct uvc_entity *entity, int rollback, struct uvc_control **err_ctrl)
1609+
struct uvc_fh *handle,
1610+
struct uvc_entity *entity,
1611+
int rollback,
1612+
struct uvc_control **err_ctrl)
16101613
{
16111614
struct uvc_control *ctrl;
16121615
unsigned int i;
@@ -1654,6 +1657,10 @@ static int uvc_ctrl_commit_entity(struct uvc_device *dev,
16541657
*err_ctrl = ctrl;
16551658
return ret;
16561659
}
1660+
1661+
if (!rollback && handle &&
1662+
ctrl->info.flags & UVC_CTRL_FLAG_ASYNCHRONOUS)
1663+
ctrl->handle = handle;
16571664
}
16581665

16591666
return 0;
@@ -1690,8 +1697,8 @@ int __uvc_ctrl_commit(struct uvc_fh *handle, int rollback,
16901697

16911698
/* Find the control. */
16921699
list_for_each_entry(entity, &chain->entities, chain) {
1693-
ret = uvc_ctrl_commit_entity(chain->dev, entity, rollback,
1694-
&err_ctrl);
1700+
ret = uvc_ctrl_commit_entity(chain->dev, handle, entity,
1701+
rollback, &err_ctrl);
16951702
if (ret < 0) {
16961703
if (ctrls)
16971704
ctrls->error_idx =
@@ -1839,9 +1846,6 @@ int uvc_ctrl_set(struct uvc_fh *handle,
18391846
mapping->set(mapping, value,
18401847
uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT));
18411848

1842-
if (ctrl->info.flags & UVC_CTRL_FLAG_ASYNCHRONOUS)
1843-
ctrl->handle = handle;
1844-
18451849
ctrl->dirty = 1;
18461850
ctrl->modified = 1;
18471851
return 0;
@@ -2163,7 +2167,7 @@ int uvc_ctrl_restore_values(struct uvc_device *dev)
21632167
ctrl->dirty = 1;
21642168
}
21652169

2166-
ret = uvc_ctrl_commit_entity(dev, entity, 0, NULL);
2170+
ret = uvc_ctrl_commit_entity(dev, NULL, entity, 0, NULL);
21672171
if (ret < 0)
21682172
return ret;
21692173
}

0 commit comments

Comments
 (0)