Skip to content

/dev/shm has permissions 755 #329

Closed

Description

@casipw

When creating a minimal devtmpfs using --dev, the directory /dev/shm has different permissions than without bubblewrap:

# ls -ld /dev/shm/
drwxrwxrwt 2 root root 40 18. Sep 08:22 /dev/shm/
# bwrap --bind / / --dev /dev ls -ld /dev/shm/
drwxr-xr-x 2 root root 40 18. Sep 08:23 /dev/shm/

This might be related to #131.

Activity

  1. smcv commented on Oct 11, 2019

    @smcv
    Collaborator

    Does it cause a user-visible bug for the permissions to be different? If yes: what can you do to reproduce that bug, what do you expect to happen, and what actually happens?

    I don't think we should be setting world-writable permissions on directories unless there is a concrete reason why it is a good idea to do so.

  2. casipw commented on Oct 11, 2019

    @casipw
    Author

    It caused a bug when I fiddled around with running a demon. With bwrap [...] runuser -u http -- [...] the daemon couldn't access /dev/shm because it was 755 and owned by root. I gave up that approach in favor of running bubblewrap as setuid, so this issue is not relevant to me any more.

  3. toralf commented on Jul 12, 2020

    @toralf

    In Gentoo we do have https://bugs.gentoo.org/496328 (python compiling fails) if /dev/shm does not have 1777 set - so it would be good to have the option to set perms on /dev/shm via command line rather than doing something like

    echo "chmod 1777 /dev/shm" > "$mnt/etc/profile.d/99_bwrap.sh"
    

    here (eg as in toralf/tinderbox@c8bc109)

  4. smcv commented on Jul 12, 2020

    @smcv
    Collaborator

    With bwrap [...] runuser -u http -- [...]

    Is that running bwrap as (real and effective) uid root?

    That isn't really what bwrap is designed for: bwrap is primarily designed to be runnable by unprivileged users, either by being setuid root (as it is on Debian and CentOS/RHEL) or by having your kernel configured to allow unprivileged users to create new user namespaces (as on Fedora and Ubuntu). Its typical uses are in things like Flatpak, GNOME thumbnailers and WebKitGTK, which run as an ordinary human user (not a system user like http) and use bwrap to protect that user's other processes from the sandboxed Flatpak app, thumbnailer or WebKit content process.

    runuser -u http -- bwrap ... would be closer to that pattern.

    In those cases, /dev/shm inside the container will be 0755 and owned by the user who started bwrap, so it doesn't need permissions that open it up to other users.

    If you're already root and fully-privileged, then you can create new namespaces with unshare(2) and configure them however you want, without needing bwrap. For example, this is how unshare(1), Docker, lxc and various systemd unit properties like ProtectSystem are implemented.

  5. cgwalters commented on Jul 12, 2020

    @cgwalters
    Collaborator

    That isn't really what bwrap is designed for: bwrap is primarily designed to be runnable by unprivileged users,

    Yes, but I think we should support the privileged case too.

    If you're already root and fully-privileged, then you can create new namespaces with unshare(2) and configure them however you want, without needing bwrap. For example, this is how unshare(1), Docker, lxc and various systemd unit properties like ProtectSystem are implemented.

    Sure, but doing all that "by hand" is exactly what bwrap is much better at - including the usual subtleties like running a proper init in the pid namespace.

    Today rpm-ostree uses bwrap running fully privileged FWIW.

    (On this particular bug...I can't see a reason not to mirror the host's permissions for /dev/shm)

  6. Maryse47 commented on Jul 13, 2020

    @Maryse47

    Created directory permissions are more generic issue than /dev/shm. Bublewrap sandbox is unusable with Qt 5.14+ due to non canonical runtime dir path permissions. Implementing #346 would be best fix IMO.

  7. added a commit that references this issue on Feb 16, 2021
  8. smcv commented on Feb 16, 2021

    @smcv
    Collaborator

    #406 implements options that would let you use --perms 1777 --tmpfs /dev/shm.

    The default continues to be 0755 to avoid behaviour changes.

  9. added a commit that references this issue on Apr 7, 2021
  10. added a commit that references this issue on Apr 19, 2021
  11. added a commit that references this issue on May 14, 2021
  12. toralf commented on Aug 21, 2021

    @toralf

    Hhm, 0.5.0 mention that it has this issue fixed, but:

    total 0
    17_1_developer-j3-20210809-220514 /var/tmp/tb # ls -ld /dev/shm
    drwxr-xr-x 2 root root 40 Aug 21 17:43 /dev/shm
    

    I do call it:

    --perms 1777 --tmpfs /dev/shm
    

    as seen here : https://github.com/toralf/tinderbox/blob/master/bin/bwrap.sh#L147

  13. smcv commented on Aug 21, 2021

    @smcv
    Collaborator
            --perms 1777 --tmpfs /dev/shm
            --dev /dev
    

    This is the wrong way round: order matters. You're mounting a tmpfs with the wider permissions on /dev/shm, but then mounting a minimal /dev (which I think might include its own /dev/shm) over the top of that. Reversing the order of these two lines should work.

  14. toralf commented on Aug 21, 2021

    @toralf
            --perms 1777 --tmpfs /dev/shm
            --dev /dev
    

    This is the wrong way round: order matters. You're mounting a tmpfs with the wider permissions on /dev/shm, but then mounting a minimal /dev (which I think might include its own /dev/shm) over the top of that. Reversing the order of these two lines should work.

    indeed - thx !

  15. added a commit that references this issue on Mar 19, 2023
  16. added a commit that references this issue on Jul 31, 2024
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