Set up an Apparmor profile to allow moving mounts for mount point
hotplug.
This fixes a regression caused by
kernel commit
157a3537d6 ("apparmor: Fix regression in mount mediation")
The commit introduced move_mount mediation, which now requires
move_mount to be allowed in the Apparmor profile. Although it is allowed
for most paths in the /usr/bin/lxc-start profile, move_mount is called
with a file descriptor instead of a path in mountpoint_insert_staged,
thus it is not affected by the allow rules in
/etc/apparmor.d/abstractions/lxc/container-base.
To fix this, introduce a new Apparmor profile to allow move_mount on
every mount, specifically for mount point hotplug.
Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
override_dh_installsystemd:
dh_installsystemd -ppve-container --no-start --no-enable --no-restart-after-upgrade -r 'system-pve\x2dcontainer.slice'
override_dh_installsystemd:
dh_installsystemd -ppve-container --no-start --no-enable --no-restart-after-upgrade -r 'system-pve\x2dcontainer.slice'
+
+override_dh_install:
+ dh_apparmor -p pve-container --profile-name=pve-container-mounthotplug
BINDIR=${PREFIX}/bin
LIBDIR=${PREFIX}/lib
SBINDIR=${PREFIX}/sbin
BINDIR=${PREFIX}/bin
LIBDIR=${PREFIX}/lib
SBINDIR=${PREFIX}/sbin
MANDIR=${PREFIX}/share/man
DOCDIR=${PREFIX}/share/doc/${PACKAGE}
LXC_SCRIPT_DIR=${PREFIX}/share/lxc
MANDIR=${PREFIX}/share/man
DOCDIR=${PREFIX}/share/doc/${PACKAGE}
LXC_SCRIPT_DIR=${PREFIX}/share/lxc
LXC_COMMON_CONFIG_DIR=${LXC_CONFIG_DIR}/common.conf.d
LXC_USERNS_CONFIG_DIR=${LXC_CONFIG_DIR}/userns.conf.d
SERVICEDIR=${DESTDIR}/lib/systemd/system
LXC_COMMON_CONFIG_DIR=${LXC_CONFIG_DIR}/common.conf.d
LXC_USERNS_CONFIG_DIR=${LXC_CONFIG_DIR}/userns.conf.d
SERVICEDIR=${DESTDIR}/lib/systemd/system
+APPARMORDDIR=${ETCDIR}/apparmor.d
PODDIR=${DOCDIR}/pod
MAN1DIR=${MANDIR}/man1/
MAN5DIR=${MANDIR}/man5/
PODDIR=${DOCDIR}/pod
MAN1DIR=${MANDIR}/man1/
MAN5DIR=${MANDIR}/man5/
gzip -9 ${MAN5DIR}/pct.conf.5
cd ${MAN5DIR}; ln -s pct.conf.5.gz ct.conf.5.gz
install -D -m 0644 10-pve-ct-inotify-limits.conf ${LIBDIR}/sysctl.d/10-pve-ct-inotify-limits.conf
gzip -9 ${MAN5DIR}/pct.conf.5
cd ${MAN5DIR}; ln -s pct.conf.5.gz ct.conf.5.gz
install -D -m 0644 10-pve-ct-inotify-limits.conf ${LIBDIR}/sysctl.d/10-pve-ct-inotify-limits.conf
+ install -D -m 0644 pve-container-mounthotplug ${APPARMORDDIR}/pve-container-mounthotplug
pve-userns.seccomp: /usr/share/lxc/config/common.seccomp
cp $< $@
pve-userns.seccomp: /usr/share/lxc/config/common.seccomp
cp $< $@
my $dir = get_staging_mount_path($opt);
# Now switch our apparmor profile before mounting:
my $dir = get_staging_mount_path($opt);
# Now switch our apparmor profile before mounting:
- my $data = 'changeprofile /usr/bin/lxc-start';
+ my $data = 'changeprofile pve-container-mounthotplug';
if (syswrite($aa_fd, $data, length($data)) != length($data)) {
die "failed to change apparmor profile: $!\n";
}
if (syswrite($aa_fd, $data, length($data)) != length($data)) {
die "failed to change apparmor profile: $!\n";
}
--- /dev/null
+#include <tunables/global>
+
+profile pve-container-mounthotplug flags=(attach_disconnected) {
+ #include <abstractions/lxc/start-container>
+
+ mount options=(move),
+}