Coder Social home page Coder Social logo

dgx-selinux's Introduction

dgx-selinux

Introduction

This project contains the SELinux policies used in DGX products.

Building and debugging

The policy module builds require that the following packages are installed:

# RHEL7
sudo yum install -y findutils \
                    selinux-policy \
                    selinux-policy-devel \
                    selinux-policy-base \
                    libselinux-utils \
                    policycoreutils \
                    policycoreutils-python

# RHEL8/RHEL9
sudo dnf install -y findutils \
                    selinux-policy \
                    selinux-policy-devel \
                    selinux-policy-base \
                    libselinux-utils \
                    policycoreutils \
                    policycoreutils-python3

While this is not required, it may be useful for debugging or just evaluating the various policies on the system.

sudo yum install -y setools-console

setools-console provides the sesearch utility, which is very useful for querying installed modules and such:

sesearch --help
sesearch --allow | grep nvidia

Pre-compiled policy modules are also included in this project under the bin/ directory. Users can install these without having to compile the policy themselves if they so desired:

sudo semodule -i nvidia-container.pp

Information

The src/<policy-module-name> directories contain the source, Makefiles, and READMEs for each policy module. Definitions for the macros used in this project can be found in /usr/share/selinux/devel/include.

Disclaimer

These SELinux policies have only been verified on DGX-1 and DGX-2 on RHEL 7.5 and 7.6. They are meant to be used as a reference for RHEL-based non-DGX platforms, not verbatim.

dgx-selinux's People

Contributors

damaestro avatar jamienguyennvidia avatar newtonliunvidia avatar psap-ci-robot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

dgx-selinux's Issues

nvidia-container policy seems to prevent connecting via SSH

Hi, I'm very happy that this SELinux policy exists! However, I seem to have found one problem:

My goal is to start a container that can access NVIDIA GPUs and that one can connect to via SSH:

  1. I start my container via:

    $ podman run --rm -it -p 10022:22 \
        --security-opt label=type:nvidia_container_t \
        nvcr.io/nvidia/cuda:11.2.2-base-centos8
  2. I can verify that GPUs are accessible, i.e., nvidia-smi returns the expected output.

  3. I now want to set up and run an SSH server inside the container:

    [root@176645926b31 /]# yum -y install openssh-server
    [root@176645926b31 /]# ssh-keygen -A
    [root@176645926b31 /]# mkdir -p /root/.ssh
    [root@176645926b31 /]# echo "YOUR_SSH_PUBLIC_KEY" > /root/.ssh/authorized_keys
    [root@176645926b31 /]# /usr/sbin/sshd -D
  4. And finally connect to it from outside. However, here, I receive the following error:

    $ ssh root@localhost -p 10022
    Connection closed by ::1 port 10022

If I repeat the above steps but without the --security-opt label=type:nvidia_container_t option, I can connect via SSH as expected (i.e., don't receive the error in the last step). Naturally, the nvidia-smi does not work in this case because it is blocked by SELinux as the nvidia-container policy is not loaded.

I am also seeing the same behavior with the nvcr.io/nvidia/cuda:11.2.2-base-centos7 image or the --cap-add ALL flag.

What is preventing the SSH connection here? Can the policy be changed to support this behavior? Or is there some option I can pass when starting the container to allow this? Thank you!

RHEL 9 support

Given these selinux policies have been useful in RHEL7 with enabling rootless containers even on non-DGX systems, it would be useful if this project added official support for such policies in RHEL9

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.