canonical / lxd

Powerful system container and virtual machine manager
https://canonical.com/lxd
GNU Affero General Public License v3.0
4.32k stars 925 forks source link

Apparmor image unpacker profile name mismatch with storage.images_volume set #10766

Closed lukts30 closed 2 years ago

lukts30 commented 2 years ago

Required information

Issue description

  1. If storage.images_volume is set then /var/lib/lxd/images becomes a symlink.
  2. For archive unpacking LXD generates an apparmor profile with the name being based on the realpath (e.g. lxd_archive-var-lib-lxd-storage-pools-zpool-custom-default_images-lxd_image_unpack_2344082808
  3. But when assigning the profile lxd assumes a static name based on /var/lib/lxd/images. : lxd_archive-var-lib-lxd-images-lxd_image_unpack_2344082808.

Information to attach

lxd_ctr_name=w11
lukas@PC  $ lxc init local:Win11 $lxd_ctr_name -p default -p extbridge -c limits.cpu=4 -c limits.memory=8GB --vm -s zpool 
Creating w11 
Error: Failed creating instance from image: Unpack failed: Failed to run: tar --restrict --force-local -C /var/lib/lxd/images/lxd_image_unpack_2344082808 --numeric-owner --xattrs-include=* -xf -: [493107] aa-exec: ERROR: profile 'lxd_archive-var-lib-lxd-images-lxd_image_unpack_2344082808' does not exist 
lukas@PC  $ sudo aa-status 
apparmor module is loaded. 
4 profiles are loaded. 
4 profiles are in enforce mode. 
  lxd_archive-var-lib-lxd-storage-pools-zpool-custom-default_images-lxd_image_unpack_2344082808 
  lxd_archive-var-lib-lxd-storage-pools-zpool-custom-default_images-lxd_image_unpack_278929189 
  lxd_archive-var-lib-lxd-storage-pools-zpool-custom-default_images-lxd_image_unpack_953680819 
  lxd_dnsmasq-lxdbr0_</var/lib/lxd> 
0 profiles are in complain mode. 
0 profiles are in kill mode. 
0 profiles are in unconfined mode. 
1 processes have profiles defined. 
1 processes are in enforce mode. 
  /usr/bin/dnsmasq (10183) lxd_dnsmasq-lxdbr0_</var/lib/lxd> 
0 processes are in complain mode. 
0 processes are unconfined but have a profile defined. 
0 processes are in mixed mode. 
0 processes are in kill mode.
[ 7231.597343] audit: type=1400 audit(1660127504.527:790): apparmor="STATUS" operation="profile_load" profile="unconfined" name="lxd_archive-var-lib-lxd-storage-pools-zpool-custom-default_images-lxd_image_unpack_2344082808" pid=493106 comm="apparmor_parser" 
[ 7231.597348] audit: type=1300 audit(1660127504.527:790): arch=c000003e syscall=1 success=yes exit=37873 a0=6 a1=563758d6e750 a2=93f1 a3=0 items=0 ppid=493105 pid=493106 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="apparmor_parser" exe="/usr/bin/apparmor_p
arser" subj==unconfined key=(null) 
[ 7231.597350] audit: type=1327 audit(1660127504.527:790): proctitle=61707061726D6F725F706172736572002D72574C002F7661722F6C69622F6C78642F73656375726974792F61707061726D6F722F6361636865002F7661722F6C69622F6C78642F73656375726974792F61707061726D6F722F70726F66696C65732F6C78645F617263686976652D7661722D6C69622D6C78642D696
D61676573 
[ 7231.598274] audit: type=1400 audit(1660127504.530:791): apparmor="DENIED" operation="change_onexec" info="label not found" error=-2 profile="unconfined" name="lxd_archive-var-lib-lxd-images-lxd_image_unpack_2344082808" pid=493107 comm="aa-exec"
simondeziel commented 2 years ago

Ah, that's what I was hitting in #10816 cause I do have that config key set:

$ lxc config show
config:
  storage.backups_volume: default/backups
  storage.images_volume: default/images
simondeziel commented 2 years ago

storage.backups_volume seems to be the key that triggers #10816. As such both keys will need special handling.

tomponline commented 2 years ago

Thanks for confirming