]> git.ipfire.org Git - thirdparty/lxc.git/commit
conf: improve read-only /sys with read-write /sys/devices/virtual/net
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 30 Jun 2021 11:22:15 +0000 (13:22 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 30 Jun 2021 11:22:15 +0000 (13:22 +0200)
commitcb4889abc83057ed6568e543bdb0a89e3941ab54
tree7e652f62f4826e47b0f9b1c04b037c6118417ab4
parent804f3e2a1259659fd4e8474a65e6ff0d9828782a
conf: improve read-only /sys with read-write /sys/devices/virtual/net

Some tools require /sys/devices/virtual/net to be read-write. At the
same time we want all other parts of /sys to be read-only. To do this we
created a layout where we hade a read-only instance of sysfs mounted on
top of a read-write instance of sysfs:

`-/sys                                  sysfs                                                        sysfs      rw,nosuid,nodev,noexec,relatime
  `-/sys                                sysfs                                                        sysfs      ro,nosuid,nodev,noexec,relatime
    |-/sys/devices/virtual/net          sysfs                                                        sysfs      rw,relatime
    | `-/sys/devices/virtual/net        sysfs[/devices/virtual/net]                                  sysfs      rw,nosuid,nodev,noexec,relatime

This causes issues for systemd services that create a separate mount
namespace as they get confused to what mount options need to be
respected.

Simplify our mounting logic so we end up with a single read-only mount
of sysfs on /sys and a read-write bind-mount of /sys/devices/virtual/net:

├─/sys                                sysfs                                                                                  sysfs         ro,nosuid,nodev,noexec,relatime
│ ├─/sys/devices/virtual/net          sysfs[/devices/virtual/net]                                                            sysfs         rw,nosuid,nodev,noexec,relatime

Link: systemd/systemd#20032
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.c