4

I have an internal webcam on my Dell laptop. I don't see it listed with lspci, but it works.

I am using a self-compiled kernel, and here are the options I have enabled:

# zcat /proc/config.gz | grep -v '^#' | egrep '(MEDIA|VIDEO)'
CONFIG_ACPI_VIDEO=y
CONFIG_MEDIA_SUPPORT=y
CONFIG_MEDIA_SUPPORT_FILTER=y
CONFIG_MEDIA_CAMERA_SUPPORT=y
CONFIG_VIDEO_DEV=y
CONFIG_MEDIA_CONTROLLER=y
CONFIG_VIDEO_V4L2=y
CONFIG_VIDEO_V4L2_I2C=y
CONFIG_MEDIA_USB_SUPPORT=y
CONFIG_USB_VIDEO_CLASS=y
CONFIG_VIDEOBUF2_CORE=y
CONFIG_VIDEOBUF2_V4L2=y
CONFIG_VIDEOBUF2_MEMOPS=y
CONFIG_VIDEOBUF2_VMALLOC=y
CONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLER=y

All options in my kernel are compiled statically, and I am not using loadable modules.

How can I disable the webcam at boot time, by passing/appending something to the kernel boot options?

I would like to decide at boot time whether I want to boot the kernel with webcam support, or without.

MC68020
  • 7,981
Martin Vegter
  • 358
  • 75
  • 236
  • 411
  • 6
    A webcam is unlikely to be a PCI device. Look for it in lsusb. – Marcus Müller Nov 06 '22 at 07:52
  • I don't see how this can be done with a kernel parameter, because with a statically linked kernel, you can't blacklist a module. Uh a kernel without module loading is usually security-wise a bad idea, as you need to include all functionality that you might eventually use always in the kernel. It's also hard to use. You're using a shared-library based userland with more than a single init executable. What was the consideration that made building a non-module-loading kernel the right choice? – Marcus Müller Nov 06 '22 at 08:19
  • @Marcus Müller - I am already using kernel boot parameters to disable some other kernel components. For example my audio card: snd-hda-intel.enable=0,1. This works fine, and I don't see why same could not work for webcam. – Martin Vegter Nov 06 '22 at 08:48
  • But it doesn't work. That enable switch is specific to the snd-hda-intel module, and doesn't exist for e.g. uvcvideo (which is most likely the driver for your webcam). Again, the fact that you're having a static kernel with everything included makes it hard to disable parts of it. You'd essentially have to choose between different kernels, instead of choosing kernel parameters, at boottime. – Marcus Müller Nov 06 '22 at 09:07
  • 3
    So: What was the consideration that made building a non-module-loading kernel the right choice? This greatly influences which kind of directions you can take from here, that's why I'm asking. You have had some consideration why you're doing this, which is central to the problem at hand, so doing the "right" thing depends on knowing the original purpose. If a solution defeats that purpose, it's not a solution for you at all, and writing it would waste everyone's time. – Marcus Müller Nov 06 '22 at 09:20
  • 1
  • Can you please provide some more information about your webcam? Do you already know which driver your webcam is using? Why do you think lspci should list your webcam? Is your webcam a PCI device? And also @MarcusMuller mentioned look for it in "lsusb", I am not really sure about this as well, This is an internal webcam and not really a USB gadget. So, Providing more information about your webcam might help to answer better. – Thushi Nov 07 '22 at 11:13
  • @Thushi internal webcams are typically connected via USB too. – Stephen Kitt Nov 07 '22 at 11:51

2 Answers2

11

If CONFIG_KALLSYMS is enabled, built-in drivers can be disabled by disabling their init function. For uvcvideo (which is likely to be the driver used for your webcam), add

initcall_blacklist=uvc_video_init

to your kernel’s command line.

If it isn’t, you won’t be able to disable only your webcam using kernel command line parameters, but you can control your webcam at run-time; find its entry in /sys/bus/usb/devices, and write 0 to the corresponding authorized file, e.g.

echo 0 | sudo tee /sys/bus/usb/devices/1-8/authorized

Write 1 to enable the camera again.

You can use USBGuard to provide control over all your USB devices, including your webcam.

Stephen Kitt
  • 434,908
  • thank you, but appending initcall_blacklist=uvc_video_init to my boot parameters has no effect. The device /dev/video0 still exists, and the webcam still works. – Martin Vegter Nov 07 '22 at 07:10
  • Does your camera use the uvcvideo driver? – Stephen Kitt Nov 07 '22 at 07:25
  • how can I find out? My laptops are Dell Latitude E6540 and Dell Latitude E7440. I believe they are using standard webcams over USB interface. – Martin Vegter Nov 07 '22 at 07:40
  • based on answer from a related question, initcall_blacklist needs CONFIG_KALLSYMS to work. But I don't have KALLSYMS in my kernel: https://unix.stackexchange.com/questions/615332/how-can-i-disable-a-kernel-driver-for-a-specific-usb-device-re-driver-is-not – Martin Vegter Nov 07 '22 at 10:08
  • Ah, you should have seen a warning in your boot logs (“initcall_blacklist requires CONFIG_KALLSYMS”). – Stephen Kitt Nov 07 '22 at 10:15
1

Not meant as an answer to the problem. Only explaining why "You just cannot!" is the only possible answer to the question as worded in the title :


It is indeed possible to pass boot parameters of the kind :

module_name.parameter_name=parameter_value

Which will be honored by some in-kernel built module_name driver at the condition the driver accepts the parameter_name and parameter_value is within the range of accepted values.

The usb-storage driver would for example be able to ignore one particular usb storage device using a boot command line parameter of the kind :

usb-storage.quirks=03f0:b002:iu

Because the usb-storage is programmed in order to honor the quirks parameter and decode its value as representing Vendor-Id:Product-Id and i meaning IGNORE_DEVICE.

If the uvcvideo driver does honor a quirks parameter, it unfortunately, offers no particular value for that parameter aiming at ignoring any device.

MC68020
  • 7,981