Skip to content

Do not mount /dev with /noexec by default #759

Closed

Description

@mythi

#725 added noexec to default /dev mount options but this triggers problems when containers try to create Intel SGX enclaves:

...
ioctl(4, SGX_IOC_ENCLAVE_ADD_PAGES, 0x7ffd38e7bf90) = 0
mmap(0x7f36d9002000, 139264, PROT_READ|PROT_EXEC, MAP_SHARED|MAP_FIXED, 4, 0) = -1 EPERM (Operation not permitted)
close(4)   

The issue where a dev node is mmap()'d with PROT_EXEC has been discussed in length on LKML and in systemd github:

systemd now allows this to be configured using ExecPaths= and NoExecPaths= but noexec is not added by default.

I've only tested this using CRI-O where containers with SGX enclaves cannot be launched with CRI-O v1.25+. This is the release where CRI-O pulled in #725 from runtime-tools.

/cc @rhatdan @mrunalp @haircommander

Activity

  1. rhatdan commented on Jan 9, 2023

    @rhatdan
    Contributor

    Since systemd changed its default, I see no reason for us not to chnage.

    @mythi Want to open a PR?

  2. mythi commented on Jan 9, 2023

    @mythi
    ContributorAuthor

    @rhatdan yes I will submit the PR on Tue

  3. mythi commented on Dec 8, 2023

    @mythi
    ContributorAuthor

    @rhatdan wanted to check here first but I believe I should submit a podman issue about this:

    I tried to try podman rootless containers with SGX and I believe it still suffers the same issue:

    $ podman run -it --rm --device /dev/sgx_enclave  --group-add keep-groups --workdir /opt/intel/sgx-sample-app   --entrypoint /bin/bash localhost/intel/sgx-sdk-demo:devel
    # mount|grep sgx_enclave
    devtmpfs on /dev/sgx_enclave type devtmpfs (rw,nosuid,noexec,relatime,size=1997876k,nr_inodes=499469,mode=755)
    

    I'm on Ubuntu 22.04 with:

    $ podman version
    Version:      3.4.4
    API Version:  3.4.4
    Go Version:   go1.18.1
    Built:        Thu Jan  1 00:00:00 1970
    OS/Arch:      linux/amd64
    
  4. rhatdan commented on Dec 8, 2023

    @rhatdan
    Contributor

    I would prefer you try this on a much more up 2 date version of Podman.

  5. mythi commented on Dec 8, 2023

    @mythi
    ContributorAuthor

    I would prefer you try this on a much more up 2 date version of Podman.

    ouch, sorry! I can update to the Kubic releases but they only give me 4.6.2 and noexec is still there:

    $ podman version
    Client:       Podman Engine
    Version:      4.6.2
    API Version:  4.6.2
    Go Version:   go1.18.1
    Built:        Thu Jan  1 00:00:00 1970
    OS/Arch:      linux/amd64
    $ podman run -it --rm --device /dev/sgx_enclave  --group-add keep-groups --workdir /opt/intel/sgx-sample-app --entrypoint /bin/bash localhost/intel/sgx-sdk-demo:devel
    root@4910ac608090:/opt/intel/sgx-sample-app# ./sgx-sample-app 
    Error: Unexpected error occurred.
    Enter a character before exit ...
    
    root@4910ac608090:/opt/intel/sgx-sample-app# mount|grep sgx_encl
    devtmpfs on /dev/sgx_enclave type devtmpfs (rw,nosuid,noexec,relatime,size=1997876k,nr_inodes=499469,mode=755)
    
  6. mythi commented on Dec 8, 2023

    @mythi
    ContributorAuthor

    ouch, sorry! I can update to the Kubic releases but they only give me 4.6.2 and noexec is still there:

    the fixed version of runtime-tools was pulled to podman in April so something else triggers that

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions