Skip to content

linux: remove sudo escalation from probe_driver and fix CI test setup - #370

Open
cshilwant wants to merge 2 commits into
OpenAMP:mainfrom
cshilwant:main
Open

linux: remove sudo escalation from probe_driver and fix CI test setup#370
cshilwant wants to merge 2 commits into
OpenAMP:mainfrom
cshilwant:main

Conversation

@cshilwant

@cshilwant cshilwant commented Sep 4, 2026

Copy link
Copy Markdown
  1. Removes the sudo modprobe fallback from metal_linux_probe_driver()
    in lib/system/linux/device.c. A library must not silently attempt
    privilege escalation on behalf of its caller - this is a security
    concern and fails on embedded/production systems where sudo
    is absent or not configured for password-less use.

  2. Updates the CI nonreg test workflow to explicitly load the required
    UIO kernel modules (uio, uio_pdrv_genirq, uio_dmem_genirq)
    before running make test, since the environment (& not the library)
    is responsible for module loading

A library must not attempt to escalate its own privileges.
The sudo modprobe fallback was incorrect for three reasons:

  1. A library silently attempting privilege escalation on behalf of its
     caller is unexpected behavior and a security concern.

  2. If modprobe failed due to missing CAP_SYS_MODULE, sudo will also
     fail unless passwordless sudo is explicitly configured in sudoers
     making the fallback redundant in practice.

  3. On embedded and production Linux systems, sudo is often not
     installed, causing system() to fail silently or hang waiting for
     a password prompt.

If the driver is not found after modprobe, return -ENODEV and let the
caller handle it.

Fixes: commit 7bda1db ("Initial commit")

Signed-off-by: Chirag Shilwant <c-shilwant@ti.com>
The nr_tests job was relying on libmetal's internal sudo modprobe
fallback in metal_linux_probe_driver() to load UIO modules at runtime.
Now that the sudo escalation has been removed from the library, the CI
environment must explicitly load the required modules before invoking
the test suite.

Add a "sudo modprobe" step for uio, uio_pdrv_genirq, and uio_dmem_genirq
prior to make test. Module loading with sudo privileges is the
responsibility of the environment, not the library.

Signed-off-by: Chirag Shilwant <c-shilwant@ti.com>
@cshilwant cshilwant changed the title linux: remove sudo modprobe fallback from metal_linux_probe_driver linux: remove sudo escalation from probe_driver and fix CI test setup Sep 4, 2026

@arnopo arnopo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with success on my PC,
Just a comment to request an extra fix of an issue i found during my test. Not mandatory, I can address it later

- name: execute test
run: |
sudo modprobe uio uio_pdrv_genirq uio_dmem_genirq
cd build

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you take opportunity to remove the cd build that is already done during build step ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each run keyword represents a new process and shell in the runner environment

@arnopo Thanks for the suggestion! As per the GitHub Actions workflow syntax reference (jobs.<job_id>.steps[*].run - https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun), doesn't each run: step spawn a new shell process, meaning the cd build from the build step would not carry over to the execute test step?

Probably also the reason why the test logs step references the full path build/Testing/Temporary/LastTest.log - https://github.com/OpenAMP/libmetal/blob/main/.github/workflows/continuous-integration.yml#L76 rather than just Testing/Temporary/LastTest.log ?

@bentheredonethat bentheredonethat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants