Skip to content

Fix SELinux detection in driver scripts#626

Open
Ashutosh0x wants to merge 1 commit into
NVIDIA:mainfrom
Ashutosh0x:fix-selinux-detection-1489
Open

Fix SELinux detection in driver scripts#626
Ashutosh0x wants to merge 1 commit into
NVIDIA:mainfrom
Ashutosh0x:fix-selinux-detection-1489

Conversation

@Ashutosh0x
Copy link
Copy Markdown

This PR replaces the outdated filesystem check [ -e /sys/fs/selinux ] with a more robust call to selinuxenabled across all driver scripts. Resolves #1489.

@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented Feb 28, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@Ashutosh0x Ashutosh0x force-pushed the fix-selinux-detection-1489 branch from e484641 to d07feae Compare February 28, 2026 18:38
@rajathagasthya
Copy link
Copy Markdown
Contributor

/ok-to-test d07feae

@rahulait
Copy link
Copy Markdown
Contributor

rahulait commented May 4, 2026

Thanks @Ashutosh0x. We removed some dirs which were not maintained by us. Please rebase the PR from latest main so that someone from the team can review the PR

@Shivkumar13 please take a look once updated.

@rajathagasthya
Copy link
Copy Markdown
Contributor

@Ashutosh0x Are you able to update your PR as per @rahulait's suggestion?

@Ashutosh0x Ashutosh0x force-pushed the fix-selinux-detection-1489 branch from d07feae to 1abd0ce Compare June 1, 2026 17:20
@Ashutosh0x
Copy link
Copy Markdown
Author

Hi @rahulait @rajathagasthya @Shivkumar13,

I have successfully rebased the branch onto the latest main and resolved all conflicts (removed the outdated/unsupported directories as requested). The branch is now clean and fully mergeable. Please take a look!

Comment thread rhel10/precompiled/nvidia-driver Outdated

echo "Check SELinux status"
if [ -e /sys/fs/selinux ]; then
if command -v selinuxenabled >/dev/null 2>&1 && selinuxenabled; then
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.

selinuxenabled is not installed by default in any of the base images. It requires libselinux-utils. So this check will always return false even if SELinux is enabled.

Make chcon calls non-fatal by appending '|| true' so that the script
does not abort when SELinux is disabled but /sys/fs/selinux is still
mounted. This avoids requiring libselinux-utils (which provides
selinuxenabled) to be installed in the container images.

For nvidia-driver scripts (rhel8, rhel9, rhel10, precompiled): retain
the existing [ -e /sys/fs/selinux ] check and add '|| true' to chcon.

For ocp_dtk_entrypoint scripts: keep the original unconditional chcon
call but make it non-fatal with '|| true'.

For vgpu-manager scripts: keep the original unconditional chcon call
but make it non-fatal with '|| true'.

Resolves #1489.

Signed-off-by: Ashutosh Kumar Singh <ashutoshkumarsingh0x@gmail.com>
@Ashutosh0x Ashutosh0x force-pushed the fix-selinux-detection-1489 branch from 1abd0ce to 29e9a32 Compare June 2, 2026 00:11
@Ashutosh0x
Copy link
Copy Markdown
Author

@rajathagasthya Good catch, thanks for pointing that out! You're right — selinuxenabled requires libselinux-utils which isn't installed in any of the base images, so the check would always return false.

I've updated the approach: instead of using selinuxenabled, I've reverted to the original [ -e /sys/fs/selinux ] filesystem check but made the chcon calls non-fatal by appending || true. This way:

  • SELinux enabled + chcon works → security context is set correctly ✅
  • SELinux disabled but /sys/fs/selinux mountedchcon fails gracefully, script continues ✅
  • SELinux fully disabledchcon is skipped entirely ✅

This avoids adding any new package dependencies while still preventing the script abort reported in #1489.

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.

3 participants