]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: uvcvideo: Introduce allow_privacy_override module parameter
authorRicardo Ribalda <ribalda@chromium.org>
Mon, 16 Mar 2026 13:34:46 +0000 (13:34 +0000)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Tue, 12 May 2026 05:30:53 +0000 (07:30 +0200)
Some camera modules have XU controls that can configure the behaviour of
the privacy LED.

Block mapping of those controls, unless the module is configured with
a new parameter: allow_privacy_override.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
[johannes.goede@oss.qualcomm.com: Remove deprecation warning from param]
Reviewed-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/usb/uvc/uvc_ctrl.c
drivers/media/usb/uvc/uvc_driver.c
drivers/media/usb/uvc/uvc_v4l2.c
drivers/media/usb/uvc/uvcvideo.h
include/linux/usb/uvc.h

index b6e020b41671979c9b78952632ea97ec9a2f2d36..3ca108b83f1da70b67a72bad6965c16d2d25a1eb 100644 (file)
@@ -3001,6 +3001,35 @@ static int uvc_ctrl_init_xu_ctrl(struct uvc_device *dev,
        return ret;
 }
 
+bool uvc_ctrl_is_privacy_control(u8 entity[16], u8 selector)
+{
+       /*
+        * This list is not exhaustive, it is a best effort to block access to
+        * non documented controls that can affect user's privacy.
+        */
+       struct privacy_control {
+               u8 entity[16];
+               u8 selector;
+       } privacy_control[] = {
+               {
+                       .entity = UVC_GUID_LOGITECH_USER_HW_CONTROL_V1,
+                       .selector = 1,
+               },
+               {
+                       .entity = UVC_GUID_LOGITECH_PERIPHERAL,
+                       .selector = 9,
+               },
+       };
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(privacy_control); i++)
+               if (!memcmp(entity, privacy_control[i].entity, 16) &&
+                   selector == privacy_control[i].selector)
+                       return true;
+
+       return false;
+}
+
 int uvc_xu_ctrl_query(struct uvc_video_chain *chain,
        struct uvc_xu_control_query *xqry)
 {
@@ -3045,6 +3074,15 @@ int uvc_xu_ctrl_query(struct uvc_video_chain *chain,
                return -ENOENT;
        }
 
+       if (uvc_ctrl_is_privacy_control(entity->guid, xqry->selector) &&
+           !uvc_allow_privacy_override_param) {
+               dev_warn_once(&chain->dev->intf->dev,
+                             "Privacy related controls can only be accessed if module parameter allow_privacy_override is true\n");
+               uvc_dbg(chain->dev, CONTROL, "Blocking access to privacy related Control %pUl/%u\n",
+                       entity->guid, xqry->selector);
+               return -EACCES;
+       }
+
        if (mutex_lock_interruptible(&chain->ctrl_mutex))
                return -ERESTARTSYS;
 
index 31b4ac3b48c1f3ed5a997508620c8f1aea92fca5..e289cc71ba986d8ced977479757782d5152129c4 100644 (file)
@@ -36,6 +36,7 @@ unsigned int uvc_no_drop_param = 1;
 static unsigned int uvc_quirks_param = -1;
 unsigned int uvc_dbg_param;
 unsigned int uvc_timeout_param = UVC_CTRL_STREAMING_TIMEOUT;
+bool uvc_allow_privacy_override_param;
 
 static struct usb_driver uvc_driver;
 
@@ -2504,6 +2505,9 @@ module_param_named(trace, uvc_dbg_param, uint, 0644);
 MODULE_PARM_DESC(trace, "Trace level bitmask");
 module_param_named(timeout, uvc_timeout_param, uint, 0644);
 MODULE_PARM_DESC(timeout, "Streaming control requests timeout");
+module_param_named(allow_privacy_override, uvc_allow_privacy_override_param, bool, 0644);
+MODULE_PARM_DESC(allow_privacy_override,
+                "Allow access to privacy related controls");
 
 /* ------------------------------------------------------------------------
  * Driver initialization and cleanup
index fa852b78919348bea4378fff1fbd189a1475ce85..644c2f1cd8e634367f552d592cd570e665679be6 100644 (file)
@@ -133,6 +133,13 @@ static int uvc_ioctl_xu_ctrl_map(struct uvc_video_chain *chain,
                return -EINVAL;
        }
 
+       if (uvc_ctrl_is_privacy_control(xmap->entity, xmap->selector) &&
+           !uvc_allow_privacy_override_param) {
+               dev_warn_once(&chain->dev->intf->dev,
+                             "Privacy related controls can only be mapped if module parameter allow_privacy_override is true\n");
+               return -EACCES;
+       }
+
        map = kzalloc_obj(*map);
        if (map == NULL)
                return -ENOMEM;
index 0a0c01b2420fccd86e9d247887e34786443bdea0..4ba35727e954e05785981495c37055b9e79f665f 100644 (file)
@@ -666,6 +666,7 @@ extern unsigned int uvc_no_drop_param;
 extern unsigned int uvc_dbg_param;
 extern unsigned int uvc_timeout_param;
 extern unsigned int uvc_hw_timestamps_param;
+extern bool uvc_allow_privacy_override_param;
 
 #define uvc_dbg(_dev, flag, fmt, ...)                                  \
 do {                                                                   \
@@ -791,6 +792,7 @@ int uvc_xu_ctrl_query(struct uvc_video_chain *chain,
                      struct uvc_xu_control_query *xqry);
 
 void uvc_ctrl_cleanup_fh(struct uvc_fh *handle);
+bool uvc_ctrl_is_privacy_control(u8 entity[16], u8 selector);
 
 /* Utility functions */
 struct usb_host_endpoint *uvc_find_endpoint(struct usb_host_interface *alts,
index 84f35c6f4d6e4220a780b7c5bafb865e84c725cf..99b070ab860f1472d6e42d50aabe0235fdb9c0a8 100644 (file)
 #define UVC_GUID_LOGITECH_PERIPHERAL \
        {0x21, 0x2d, 0xe5, 0xff, 0x30, 0x80, 0x2c, 0x4e, \
         0x82, 0xd9, 0xf5, 0x87, 0xd0, 0x05, 0x40, 0xbd }
+#define UVC_GUID_LOGITECH_USER_HW_CONTROL_V1 \
+       {0x82, 0x06, 0x61, 0x63, 0x70, 0x50, 0xab, 0x49, \
+        0xb8, 0xcc, 0xb3, 0x85, 0x5e, 0x8d, 0x22, 0x1f }
+
 
 /* https://learn.microsoft.com/en-us/windows-hardware/drivers/stream/uvc-extensions-1-5#222-extension-unit-controls */
 #define UVC_MSXU_CONTROL_FOCUS                 0x01