Skip to content

About

πŸŽ₯ v4l2loopback – Secure Boot Management for Fedora

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

34 Commits

Folders and files

Repository files navigation

πŸŽ₯ v4l2loopback Manager for Fedora

Secure Boot-aware management of the upstream v4l2loopback kernel module on Fedora.

Fedora COPR License: GPL-3.0 Release

v4l2loopback-manager builds, signs, installs, verifies, rebuilds, and removes the upstream v4l2loopback kernel module on Fedora systems, including systems with UEFI Secure Boot enabled.

The kernel module itself is not distributed by this RPM. It is built locally from the upstream source for Fedora's configured default boot kernel.


✨ Features

  • Builds v4l2loopback locally for the Fedora default boot kernel.
  • Detects the target kernel using grubby --default-kernel.
  • Supports UEFI Secure Boot using a Machine Owner Key (MOK).
  • Signs v4l2loopback.ko using the kernel sign-file utility.
  • Verifies module existence, expected certificate signer, and current MOK enrollment.
  • Provides a status command for a complete Secure Boot/signing health check.
  • Rebuilds only when the module is missing or has an invalid signature.
  • Provides optional systemd integration for automatic boot-time verification.
  • Keeps module options persistent through modprobe.d.
  • Supports explicit local-resource uninstall, systemd cleanup, and complete RPM purge.
  • Designed for Fedora RPM/COPR installation.

πŸš€ Quick Start

Install from COPR

sudo dnf copr enable hhlp/v4l2loopback
sudo dnf install v4l2loopback-manager

Verify the installation:

rpm -q v4l2loopback-manager
command -v v4l2loopback
v4l2loopback help

Prepare the Secure Boot signing key and MOK enrollment:

sudo v4l2loopback genkey

If enrollment is requested, reboot manually and complete enrollment in the blue MOK Manager screen. Existing complete signing keys are preserved; the manager does not regenerate them merely because enrollment is missing.

Check the current signing state:

v4l2loopback status

After MOK enrollment is complete, build and install the module:

sudo v4l2loopback rebuild

Optional automatic boot-time verification:

sudo v4l2loopback enable-systemd

πŸ—οΈ How It Works

The RPM provides the manager, not a precompiled kernel module.

                    Fedora system
                         β”‚
                         β–Ό
              v4l2loopback-manager
                         β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚              β”‚              β”‚
          β–Ό              β–Ό              β–Ό
    default kernel   Secure Boot     upstream source
       grubby            MOK        v4l2loopback.git
          β”‚              β”‚              β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β–Ό
                  build module
                         β”‚
                         β–Ό
                 sign module
                         β”‚
                         β–Ό
       /lib/modules/<kernel>/updates/
                 v4l2loopback.ko
                         β”‚
                         β–Ό
                      depmod

At boot, the optional systemd service performs a simple decision:

             Fedora default boot kernel
                        β”‚
                        β–Ό
              v4l2loopback.ko
                        β”‚
                 β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”
                 β”‚             β”‚
              missing        exists
                 β”‚             β”‚
                 β”‚             β–Ό
                 β”‚        check signer
                 β”‚         β”Œβ”€β”€β”€β”΄β”€β”€β”€β”
                 β”‚         β”‚       β”‚
                 β”‚       valid   invalid
                 β”‚         β”‚       β”‚
                 β–Ό         β–Ό       β–Ό
              rebuild     skip   rebuild

πŸ“š Table of Contents


Current Design

The manager deliberately has no DNF hook and no systemd timer.

The optional:

v4l2loopback-rebuild.service

is a oneshot service evaluated at boot.

The target kernel is the Fedora default boot kernel, determined with:

sudo grubby --default-kernel

The same target is used by both:

needs-rebuild
rebuild

The manager does not simply choose the numerically newest installed kernel-devel.

For the target kernel it expects:

/lib/modules/<default-boot-kernel>/updates/v4l2loopback.ko

needs-rebuild validates the target module and keeps module validity separate from MOK trust:

  1. The module exists.
  2. modinfo -F signer contains V4L2Loopback Module Signing.
  3. MOK enrollment is checked so a lost enrollment can be reported clearly.

A missing MOK enrollment does not make an already valid .ko require a rebuild. Rebuilding with the same unenrolled key would not restore trust.

Its exit status is intentionally designed for systemd ExecCondition=:

0 = module missing, unsigned, unreadable,
    or signed by another certificate
    β†’ rebuild required

1 = module exists and has the expected signer
    β†’ no rebuild required

Important: exit status 1 from needs-rebuild is not an application failure. It means the systemd condition is false because the module is already valid.


Requirements

The RPM installs the required runtime dependencies automatically.

For a manual/source installation, the required Fedora packages are:

sudo dnf install -y \
    git \
    gcc \
    make \
    kernel-devel \
    openssl \
    mokutil \
    dracut \
    kmod \
    systemd \
    grubby

Optional diagnostic tools:

sudo dnf install -y v4l-utils ShellCheck

RPM / COPR Installation

Enable the COPR repository:

sudo dnf copr enable hhlp/v4l2loopback

Install:

sudo dnf install v4l2loopback-manager

The RPM installs the manager as:

/usr/bin/v4l2loopback

Verify:

rpm -q v4l2loopback-manager
rpm -qf /usr/bin/v4l2loopback
command -v v4l2loopback
v4l2loopback help

What the RPM installs

The RPM packages the management utility and documentation.

It deliberately does not ship a precompiled v4l2loopback.ko.

RPM
 β”‚
 β”œβ”€β”€ /usr/bin/v4l2loopback
 β”œβ”€β”€ README.md
 β”œβ”€β”€ FAQ.md
 β”œβ”€β”€ TEST.md
 └── LICENSE

v4l2loopback.ko
      β–²
      β”‚
built locally for the
Fedora default boot kernel

This avoids coupling the package to one particular Fedora kernel build.


Commands

Available commands:

genkey
status
needs-rebuild
rebuild
reinstall
uninstall
purge
enable-systemd
disable-systemd
help

General syntax:

sudo v4l2loopback <command>

Display built-in help:

v4l2loopback help

Secure Boot / MOK

Generate the project MOK:

sudo v4l2loopback genkey

The manager uses:

/var/lib/shim-signed/mok/v4l.key
/var/lib/shim-signed/mok/v4l.der

Certificate subject:

CN=V4L2Loopback Module Signing

The private key:

/var/lib/shim-signed/mok/v4l.key

must remain private and should never be committed, uploaded, or attached to a GitHub issue.

genkey is intentionally conservative:

both files missing
    -> generate a new key pair

both files present
    -> preserve the existing key pair

only one file present
    -> stop; do not overwrite the partial key pair

certificate not enrolled
    -> import the existing DER certificate for MOK enrollment

If enrollment is requested, reboot manually:

sudo reboot

Then complete enrollment in the blue MOK Manager screen.

Verify the current state with the manager:

v4l2loopback status

You can also inspect the enrolled certificates directly:

mokutil --list-enrolled |
    grep -A5 -B5 'V4L2Loopback Module Signing'

On some Fedora/mokutil combinations, mokutil --test-key may print is already enrolled while still returning exit status 1. The manager therefore checks the explicit enrollment result instead of trusting that exit code alone.


Source Tree

The manager expects the upstream source at:

/usr/src/v4l2loopback

Clone it when needed:

sudo git clone \
    https://github.com/v4l2loopback/v4l2loopback.git \
    /usr/src/v4l2loopback

The source comes from the upstream v4l2loopback project. This repository provides the Fedora management, Secure Boot, packaging, and systemd integration around it.


Kernel Selection

Version 1.0.2 uses Fedora's configured default boot kernel.

Show it with:

sudo grubby --default-kernel

Example:

/boot/vmlinuz-7.1.10-200.fc44.x86_64

The manager extracts:

7.1.10-200.fc44.x86_64

and expects the corresponding kernel paths:

/usr/src/kernels/7.1.10-200.fc44.x86_64
/lib/modules/7.1.10-200.fc44.x86_64

This distinction is important.

newest installed kernel
          β‰ 
Fedora configured default boot kernel

The manager follows the kernel Fedora is configured to boot.

If kernel-devel for that kernel is missing, install the matching package before rebuilding.


Rebuild Decision

The rebuild decision is:

Fedora default boot kernel
          β”‚
          β–Ό
expected v4l2loopback.ko
          β”‚
     β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”
     β”‚         β”‚
   missing    exists
     β”‚         β”‚
     β”‚         β–Ό
     β”‚     check signer
     β”‚      β”Œβ”€β”€β”΄β”€β”€β”
     β”‚      β”‚     β”‚
     β”‚    valid invalid
     β”‚      β”‚     β”‚
     β–Ό      β–Ό     β–Ό
 rebuild   skip  rebuild

Run the condition manually:

sudo v4l2loopback needs-rebuild
echo $?

Interpretation:

0 β†’ rebuild required
1 β†’ module already valid

Perform the build:

sudo v4l2loopback rebuild

rebuild independently checks the same target and signature. Therefore, a manual rebuild also avoids recompiling an already valid module.

If the module exists but is unsigned or signed by another certificate, it is rebuilt and replaced.

Build pipeline

make clean
    β”‚
    β–Ό
make KERNELRELEASE=<default-boot-kernel>
    β”‚
    β–Ό
kernel sign-file sha256
    β”‚
    β–Ό
install v4l2loopback.ko
    β”‚
    β–Ό
depmod -a <kernel>

The module is reloaded immediately only when:

target kernel == uname -r

Otherwise, the module is prepared for the next boot into the target kernel.


systemd Integration

Enable automatic boot-time checking:

sudo v4l2loopback enable-systemd

The manager generates:

v4l2loopback-rebuild.service

with the equivalent logic:

[Unit]
Description=Ensure v4l2loopback is available for Fedora default boot kernel
Documentation=https://github.com/hhlp/v4l2loopback
After=local-fs.target
ConditionPathExists=/usr/bin/v4l2loopback

[Service]
Type=oneshot
ExecCondition=/usr/bin/v4l2loopback needs-rebuild
ExecStart=/usr/bin/v4l2loopback rebuild

[Install]
WantedBy=multi-user.target

The boot flow is:

boot
 β”‚
 β–Ό
v4l2loopback-rebuild.service
 β”‚
 β–Ό
needs-rebuild
 β”‚
 β”œβ”€β”€ exit 0 ──► ExecStart=rebuild
 β”‚
 └── exit 1 ──► skip ExecStart

At every boot, systemd evaluates the condition.

Exit 1 from needs-rebuild means the module is already valid, so ExecStart= is intentionally skipped.

systemd may display:

ExecCondition=... (code=exited, status=1/FAILURE)

followed by:

Skipped due to 'exec-condition'

In this design that is an expected false condition, not a failed compilation or broken service.

Check the service:

systemctl status v4l2loopback-rebuild.service
systemctl is-enabled v4l2loopback-rebuild.service
journalctl -b -u v4l2loopback-rebuild.service

Disable and remove the dynamically generated unit:

sudo v4l2loopback disable-systemd

If upgrading from an older release whose generated unit already exists, enable-systemd preserves that file.

To regenerate its contents using the current version:

sudo v4l2loopback disable-systemd
sudo v4l2loopback enable-systemd

Persistent Module Configuration

The manager uses:

/etc/modprobe.d/v4l2loopback.conf
/etc/modules-load.d/v4l2loopback.conf

Default module options:

devices=1 video_nr=10 card_label=VirtualCam exclusive_caps=1

These settings provide a persistent virtual camera configuration across boots.


Verification

Start with the built-in health check:

v4l2loopback status

A healthy Secure Boot setup reports the signing certificate as enrolled, the target module as present and signed by V4L2Loopback Module Signing, and ends with:

βœ… v4l2loopback signing state is ready.

Determine the Fedora default boot kernel manually:

TARGET="$(sudo grubby --default-kernel)"
TARGET="${TARGET##*/}"
TARGET="${TARGET#vmlinuz-}"

echo "$TARGET"

Inspect the module:

modinfo -k "$TARGET" v4l2loopback |
    grep -E '^(filename|version|signer|sig_key|sig_hashalgo):'

Expected signer:

V4L2Loopback Module Signing

For the currently running kernel:

lsmod | grep v4l2loopback

If v4l-utils is installed:

v4l2-ctl --list-devices

A normal installation should expose the configured virtual camera, by default:

VirtualCam

BIOS / UEFI / Firmware Recovery

A BIOS/UEFI or firmware update can change Secure Boot/MOK trust state without removing the local key files or the already signed module.

Typical state:

v4l.key exists
v4l.der exists
v4l2loopback.ko exists
module signer is correct
MOK enrollment is missing

In that case, do not regenerate the key and do not rebuild the module just to restore trust. Re-enroll the existing certificate:

sudo v4l2loopback genkey

The manager preserves the existing key pair and stages the existing v4l.der for enrollment. Then reboot manually:

sudo reboot

Complete the MOK enrollment in the blue MOK Manager screen and verify:

v4l2loopback status

The expected result is:

πŸ” MOK enrollment:
   βœ… Signing certificate is enrolled.

βœ… v4l2loopback signing state is ready.

Kernel Updates

After:

sudo dnf upgrade

Fedora normally changes its configured default boot kernel to the newly installed kernel.

On the next boot:

Fedora boot
    β”‚
    β–Ό
systemd oneshot
    β”‚
    β–Ό
grubby --default-kernel
    β”‚
    β–Ό
check v4l2loopback.ko
    β”‚
    β–Ό
check signer
    β”‚
 β”Œβ”€β”€β”΄β”€β”€β”€β”
 β”‚      β”‚
valid invalid/missing
 β”‚      β”‚
skip  rebuild

The manager therefore follows the kernel Fedora is configured to boot, rather than assuming that the highest installed kernel-devel is always the intended kernel.

There is deliberately:

  • no DNF hook;
  • no background timer;
  • no unnecessary rebuild when the module is already valid.

Removal

Because the manager creates local system state that does not belong directly to the RPM payload, cleanup should be explicit.

Remove managed local resources but keep the RPM

Run:

sudo v4l2loopback uninstall

uninstall disables and removes the dynamically generated systemd integration, unloads the module when possible, removes locally installed v4l2loopback.ko files and persistent module configuration, and offers the existing optional cleanup of the upstream source tree, signing keys, and MOK certificate deletion request.

The manager RPM remains installed, so /usr/bin/v4l2loopback is still available afterwards.

If MOK certificate deletion is requested, mokutil --delete only stages the request. The certificate remains enrolled until you reboot manually and confirm the pending deletion in the blue MOK Manager screen.

Complete purge including the manager RPM

Recommended complete-removal command:

sudo v4l2loopback purge

The purge flow is:

uninstall managed local resources
        β”‚
        β–Ό
disable/remove systemd integration
        β”‚
        β–Ό
optional MOK deletion request
        β”‚
        β–Ό
dnf remove v4l2loopback-manager

DNF keeps its normal final transaction confirmation; the manager does not pass -y.

If MOK deletion was successfully staged, the RPM and local resources can be removed before reboot, but the overall purge remains pending until the manual MOK Manager confirmation is completed.

RPM removal:            complete
Local resource cleanup: complete
MOK deletion request:   pending reboot confirmation
Overall purge:          pending

No automatic reboot is performed.

A direct:

sudo dnf remove v4l2loopback-manager

removes only RPM-owned files. RPM scriptlets intentionally do not perform interactive cleanup of locally generated modules, signing material, source trees, configuration, or dynamically generated systemd state.


Documentation

Additional project documentation:

Document Purpose
FAQ.md Troubleshooting and frequently asked questions
TEST.md Validation and testing procedure
CHANGELOG.md Release history and notable changes
CONTRIBUTING.md Contribution workflow and development guidelines
SECURITY.md Security policy and vulnerability reporting
LICENSE GPL-3.0 license

Project Scope

This project manages the build and installation of the upstream v4l2loopback module on Fedora.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ hhlp/v4l2loopback                          β”‚
β”‚                                            β”‚
β”‚ Fedora management                          β”‚
β”‚ RPM / COPR packaging                       β”‚
β”‚ Secure Boot / MOK signing                  β”‚
β”‚ systemd integration                        β”‚
β”‚ verification / rebuild logic               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚
                    β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ upstream v4l2loopback                      β”‚
β”‚                                            β”‚
β”‚ actual Linux kernel module source          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Issues related specifically to the upstream kernel module itself may need to be reported to the upstream v4l2loopback project.


License

v4l2loopback-manager is distributed under the GNU General Public License v3.0 only (GPL-3.0-only).

See LICENSE for the complete license text.


Current release: v1.0.5 Platform: Fedora Linux Manager: /usr/bin/v4l2loopback Kernel target: Fedora default boot kernel via grubby --default-kernel

About

πŸŽ₯ v4l2loopback – Secure Boot Management for Fedora

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages