In preparation for an SRU, here is a minimal C testcase provided by Wolfgang Bumiller:
``` /* # apparmor_parser -r /etc/apparmor.d/bug-profile # (tested without the flags here as well btw.) profile bug-profile flags=(attach_disconnected,mediate_deleted) { network, file, unix, } # gcc this.c # ./a.out lock = 2 (Success) # aa-exec -p bug-profile ./a.out lock = 2 (Permission denied) kernel: audit: type=1400 audit(1530774919.510:93): apparmor="DENIED" operation="file_lock" profile="bug-profile" pid=21788 comm="a.out" family="unix" sock_type="dgram" protocol=0 addr=none */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/file.h> int main(int argc, char **argv) { int sp[2]; if (socketpair(AF_UNIX, SOCK_DGRAM, 0, sp) != 0) { perror("socketpair"); exit(1); } int rc = flock(sp[0], LOCK_EX); printf("lock = %i (%m)\n"); close(sp[0]); close(sp[1]); return 0; } ``` Another very easy way to reproduce the issue is to run "hostnamectl status" inside a container which will hang as the systemd unit (socket activated) will fail to trigger. -- You received this bug notification because you are a member of Kernel Packages, which is subscribed to linux in Ubuntu. https://bugs.launchpad.net/bugs/1780227 Title: locking sockets broken due to missing AppArmor socket mediation patches Status in apparmor package in Ubuntu: Triaged Status in linux package in Ubuntu: Invalid Status in apparmor source package in Xenial: Triaged Status in linux source package in Xenial: Invalid Status in apparmor source package in Bionic: Triaged Status in linux source package in Bionic: Invalid Bug description: Hey, Newer systemd makes use of locks placed on AF_UNIX sockets created with the socketpair() syscall to synchronize various bits and pieces when isolating services. On kernels prior to 4.18 that do not have backported the AppArmor socket mediation patchset this will cause the locks to be denied with EACCESS. This causes systemd to be broken in LXC and LXD containers that do not run unconfined which is a pretty big deal. We have seen various bug reports related to this. See for example [1] and [2]. If feasible it would be excellent if we could backport the socket mediation patchset to all LTS kernels. Afaict, this should be 4.4 and 4.15. This will unbreak a whole range of use-cases. The socket mediation patchset is available here: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=80a17a5f501ea048d86f81d629c94062b76610d4 [1]: https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/1575779 [2]: https://github.com/systemd/systemd/issues/9493 Thanks! Christian To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/1780227/+subscriptions -- Mailing list: https://launchpad.net/~kernel-packages Post to : kernel-packages@lists.launchpad.net Unsubscribe : https://launchpad.net/~kernel-packages More help : https://help.launchpad.net/ListHelp