From 2c3cab4f9d5fc81aa139bc87e4010eccc46d8e6b Mon Sep 17 00:00:00 2001 From: Catherine Redfield Date: Thu, 8 Feb 2024 16:14:37 -0500 Subject: [PATCH 1/3] feat: add 5.15 apparmor directory (LP: #2052789) After the kernel roll to linux-gcp-5.15-5.15.0-1051.59_20.04.1, basic_ubuntu::test_snap_preseed_optimized began failuring due to a preseed mismatch. This change adds a 5.15 apparmor configuration to the focal branch. (cherry picked from commit 76628691f5e584bde009f71d05c2057a624445d5) --- live-build/apparmor/5.15/capability | 1 + live-build/apparmor/5.15/caps/mask | 1 + live-build/apparmor/5.15/dbus/mask | 1 + live-build/apparmor/5.15/domain/attach_conditions/xattr | 1 + live-build/apparmor/5.15/domain/change_hat | 1 + live-build/apparmor/5.15/domain/change_hatv | 1 + live-build/apparmor/5.15/domain/change_onexec | 1 + live-build/apparmor/5.15/domain/change_profile | 1 + live-build/apparmor/5.15/domain/computed_longest_left | 1 + live-build/apparmor/5.15/domain/fix_binfmt_elf_mmap | 1 + live-build/apparmor/5.15/domain/post_nnp_subset | 1 + live-build/apparmor/5.15/domain/stack | 1 + live-build/apparmor/5.15/domain/version | 1 + live-build/apparmor/5.15/file/mask | 1 + live-build/apparmor/5.15/ipc/posix_mqueue | 1 + live-build/apparmor/5.15/mount/mask | 1 + live-build/apparmor/5.15/namespaces/pivot_root | 1 + live-build/apparmor/5.15/namespaces/profile | 1 + live-build/apparmor/5.15/network/af_mask | 1 + live-build/apparmor/5.15/network/af_unix | 1 + live-build/apparmor/5.15/network_v8/af_mask | 1 + live-build/apparmor/5.15/policy/set_load | 1 + live-build/apparmor/5.15/policy/versions/v5 | 1 + live-build/apparmor/5.15/policy/versions/v6 | 1 + live-build/apparmor/5.15/policy/versions/v7 | 1 + live-build/apparmor/5.15/policy/versions/v8 | 1 + live-build/apparmor/5.15/ptrace/mask | 1 + live-build/apparmor/5.15/query/label/data | 1 + live-build/apparmor/5.15/query/label/multi_transaction | 1 + live-build/apparmor/5.15/query/label/perms | 1 + live-build/apparmor/5.15/rlimit/mask | 1 + live-build/apparmor/5.15/signal/mask | 1 + 32 files changed, 32 insertions(+) create mode 100644 live-build/apparmor/5.15/capability create mode 100644 live-build/apparmor/5.15/caps/mask create mode 100644 live-build/apparmor/5.15/dbus/mask create mode 100644 live-build/apparmor/5.15/domain/attach_conditions/xattr create mode 100644 live-build/apparmor/5.15/domain/change_hat create mode 100644 live-build/apparmor/5.15/domain/change_hatv create mode 100644 live-build/apparmor/5.15/domain/change_onexec create mode 100644 live-build/apparmor/5.15/domain/change_profile create mode 100644 live-build/apparmor/5.15/domain/computed_longest_left create mode 100644 live-build/apparmor/5.15/domain/fix_binfmt_elf_mmap create mode 100644 live-build/apparmor/5.15/domain/post_nnp_subset create mode 100644 live-build/apparmor/5.15/domain/stack create mode 100644 live-build/apparmor/5.15/domain/version create mode 100644 live-build/apparmor/5.15/file/mask create mode 100644 live-build/apparmor/5.15/ipc/posix_mqueue create mode 100644 live-build/apparmor/5.15/mount/mask create mode 100644 live-build/apparmor/5.15/namespaces/pivot_root create mode 100644 live-build/apparmor/5.15/namespaces/profile create mode 100644 live-build/apparmor/5.15/network/af_mask create mode 100644 live-build/apparmor/5.15/network/af_unix create mode 100644 live-build/apparmor/5.15/network_v8/af_mask create mode 100644 live-build/apparmor/5.15/policy/set_load create mode 100644 live-build/apparmor/5.15/policy/versions/v5 create mode 100644 live-build/apparmor/5.15/policy/versions/v6 create mode 100644 live-build/apparmor/5.15/policy/versions/v7 create mode 100644 live-build/apparmor/5.15/policy/versions/v8 create mode 100644 live-build/apparmor/5.15/ptrace/mask create mode 100644 live-build/apparmor/5.15/query/label/data create mode 100644 live-build/apparmor/5.15/query/label/multi_transaction create mode 100644 live-build/apparmor/5.15/query/label/perms create mode 100644 live-build/apparmor/5.15/rlimit/mask create mode 100644 live-build/apparmor/5.15/signal/mask diff --git a/live-build/apparmor/5.15/capability b/live-build/apparmor/5.15/capability new file mode 100644 index 00000000..96a10b97 --- /dev/null +++ b/live-build/apparmor/5.15/capability @@ -0,0 +1 @@ +0xffffff diff --git a/live-build/apparmor/5.15/caps/mask b/live-build/apparmor/5.15/caps/mask new file mode 100644 index 00000000..1a8d13ec --- /dev/null +++ b/live-build/apparmor/5.15/caps/mask @@ -0,0 +1 @@ +chown dac_override dac_read_search fowner fsetid kill setgid setuid setpcap linux_immutable net_bind_service net_broadcast net_admin net_raw ipc_lock ipc_owner sys_module sys_rawio sys_chroot sys_ptrace sys_pacct sys_admin sys_boot sys_nice sys_resource sys_time sys_tty_config mknod lease audit_write audit_control setfcap mac_override mac_admin syslog wake_alarm block_suspend audit_read diff --git a/live-build/apparmor/5.15/dbus/mask b/live-build/apparmor/5.15/dbus/mask new file mode 100644 index 00000000..1248078e --- /dev/null +++ b/live-build/apparmor/5.15/dbus/mask @@ -0,0 +1 @@ +acquire send receive diff --git a/live-build/apparmor/5.15/domain/attach_conditions/xattr b/live-build/apparmor/5.15/domain/attach_conditions/xattr new file mode 100644 index 00000000..7cfab5b0 --- /dev/null +++ b/live-build/apparmor/5.15/domain/attach_conditions/xattr @@ -0,0 +1 @@ +yes diff --git a/live-build/apparmor/5.15/domain/change_hat b/live-build/apparmor/5.15/domain/change_hat new file mode 100644 index 00000000..7cfab5b0 --- /dev/null +++ b/live-build/apparmor/5.15/domain/change_hat @@ -0,0 +1 @@ +yes diff --git a/live-build/apparmor/5.15/domain/change_hatv b/live-build/apparmor/5.15/domain/change_hatv new file mode 100644 index 00000000..7cfab5b0 --- /dev/null +++ b/live-build/apparmor/5.15/domain/change_hatv @@ -0,0 +1 @@ +yes diff --git a/live-build/apparmor/5.15/domain/change_onexec b/live-build/apparmor/5.15/domain/change_onexec new file mode 100644 index 00000000..7cfab5b0 --- /dev/null +++ b/live-build/apparmor/5.15/domain/change_onexec @@ -0,0 +1 @@ +yes diff --git a/live-build/apparmor/5.15/domain/change_profile b/live-build/apparmor/5.15/domain/change_profile new file mode 100644 index 00000000..7cfab5b0 --- /dev/null +++ b/live-build/apparmor/5.15/domain/change_profile @@ -0,0 +1 @@ +yes diff --git a/live-build/apparmor/5.15/domain/computed_longest_left b/live-build/apparmor/5.15/domain/computed_longest_left new file mode 100644 index 00000000..7cfab5b0 --- /dev/null +++ b/live-build/apparmor/5.15/domain/computed_longest_left @@ -0,0 +1 @@ +yes diff --git a/live-build/apparmor/5.15/domain/fix_binfmt_elf_mmap b/live-build/apparmor/5.15/domain/fix_binfmt_elf_mmap new file mode 100644 index 00000000..7cfab5b0 --- /dev/null +++ b/live-build/apparmor/5.15/domain/fix_binfmt_elf_mmap @@ -0,0 +1 @@ +yes diff --git a/live-build/apparmor/5.15/domain/post_nnp_subset b/live-build/apparmor/5.15/domain/post_nnp_subset new file mode 100644 index 00000000..7cfab5b0 --- /dev/null +++ b/live-build/apparmor/5.15/domain/post_nnp_subset @@ -0,0 +1 @@ +yes diff --git a/live-build/apparmor/5.15/domain/stack b/live-build/apparmor/5.15/domain/stack new file mode 100644 index 00000000..7cfab5b0 --- /dev/null +++ b/live-build/apparmor/5.15/domain/stack @@ -0,0 +1 @@ +yes diff --git a/live-build/apparmor/5.15/domain/version b/live-build/apparmor/5.15/domain/version new file mode 100644 index 00000000..5625e59d --- /dev/null +++ b/live-build/apparmor/5.15/domain/version @@ -0,0 +1 @@ +1.2 diff --git a/live-build/apparmor/5.15/file/mask b/live-build/apparmor/5.15/file/mask new file mode 100644 index 00000000..087b6771 --- /dev/null +++ b/live-build/apparmor/5.15/file/mask @@ -0,0 +1 @@ +create read write exec append mmap_exec link lock diff --git a/live-build/apparmor/5.15/ipc/posix_mqueue b/live-build/apparmor/5.15/ipc/posix_mqueue new file mode 100644 index 00000000..c20f9f93 --- /dev/null +++ b/live-build/apparmor/5.15/ipc/posix_mqueue @@ -0,0 +1 @@ +create read write open delete setattr getattr diff --git a/live-build/apparmor/5.15/mount/mask b/live-build/apparmor/5.15/mount/mask new file mode 100644 index 00000000..652c8796 --- /dev/null +++ b/live-build/apparmor/5.15/mount/mask @@ -0,0 +1 @@ +mount umount pivot_root diff --git a/live-build/apparmor/5.15/namespaces/pivot_root b/live-build/apparmor/5.15/namespaces/pivot_root new file mode 100644 index 00000000..7ecb56eb --- /dev/null +++ b/live-build/apparmor/5.15/namespaces/pivot_root @@ -0,0 +1 @@ +no diff --git a/live-build/apparmor/5.15/namespaces/profile b/live-build/apparmor/5.15/namespaces/profile new file mode 100644 index 00000000..7cfab5b0 --- /dev/null +++ b/live-build/apparmor/5.15/namespaces/profile @@ -0,0 +1 @@ +yes diff --git a/live-build/apparmor/5.15/network/af_mask b/live-build/apparmor/5.15/network/af_mask new file mode 100644 index 00000000..503289e7 --- /dev/null +++ b/live-build/apparmor/5.15/network/af_mask @@ -0,0 +1 @@ +unspec unix inet ax25 ipx appletalk netrom bridge atmpvc x25 inet6 rose netbeui security key netlink packet ash econet atmsvc rds sna irda pppox wanpipe llc ib mpls can tipc bluetooth iucv rxrpc isdn phonet ieee802154 caif alg nfc vsock kcm qipcrtr smc xdp diff --git a/live-build/apparmor/5.15/network/af_unix b/live-build/apparmor/5.15/network/af_unix new file mode 100644 index 00000000..7cfab5b0 --- /dev/null +++ b/live-build/apparmor/5.15/network/af_unix @@ -0,0 +1 @@ +yes diff --git a/live-build/apparmor/5.15/network_v8/af_mask b/live-build/apparmor/5.15/network_v8/af_mask new file mode 100644 index 00000000..503289e7 --- /dev/null +++ b/live-build/apparmor/5.15/network_v8/af_mask @@ -0,0 +1 @@ +unspec unix inet ax25 ipx appletalk netrom bridge atmpvc x25 inet6 rose netbeui security key netlink packet ash econet atmsvc rds sna irda pppox wanpipe llc ib mpls can tipc bluetooth iucv rxrpc isdn phonet ieee802154 caif alg nfc vsock kcm qipcrtr smc xdp diff --git a/live-build/apparmor/5.15/policy/set_load b/live-build/apparmor/5.15/policy/set_load new file mode 100644 index 00000000..7cfab5b0 --- /dev/null +++ b/live-build/apparmor/5.15/policy/set_load @@ -0,0 +1 @@ +yes diff --git a/live-build/apparmor/5.15/policy/versions/v5 b/live-build/apparmor/5.15/policy/versions/v5 new file mode 100644 index 00000000..7cfab5b0 --- /dev/null +++ b/live-build/apparmor/5.15/policy/versions/v5 @@ -0,0 +1 @@ +yes diff --git a/live-build/apparmor/5.15/policy/versions/v6 b/live-build/apparmor/5.15/policy/versions/v6 new file mode 100644 index 00000000..7cfab5b0 --- /dev/null +++ b/live-build/apparmor/5.15/policy/versions/v6 @@ -0,0 +1 @@ +yes diff --git a/live-build/apparmor/5.15/policy/versions/v7 b/live-build/apparmor/5.15/policy/versions/v7 new file mode 100644 index 00000000..7cfab5b0 --- /dev/null +++ b/live-build/apparmor/5.15/policy/versions/v7 @@ -0,0 +1 @@ +yes diff --git a/live-build/apparmor/5.15/policy/versions/v8 b/live-build/apparmor/5.15/policy/versions/v8 new file mode 100644 index 00000000..7cfab5b0 --- /dev/null +++ b/live-build/apparmor/5.15/policy/versions/v8 @@ -0,0 +1 @@ +yes diff --git a/live-build/apparmor/5.15/ptrace/mask b/live-build/apparmor/5.15/ptrace/mask new file mode 100644 index 00000000..10fc201a --- /dev/null +++ b/live-build/apparmor/5.15/ptrace/mask @@ -0,0 +1 @@ +read trace diff --git a/live-build/apparmor/5.15/query/label/data b/live-build/apparmor/5.15/query/label/data new file mode 100644 index 00000000..7cfab5b0 --- /dev/null +++ b/live-build/apparmor/5.15/query/label/data @@ -0,0 +1 @@ +yes diff --git a/live-build/apparmor/5.15/query/label/multi_transaction b/live-build/apparmor/5.15/query/label/multi_transaction new file mode 100644 index 00000000..7cfab5b0 --- /dev/null +++ b/live-build/apparmor/5.15/query/label/multi_transaction @@ -0,0 +1 @@ +yes diff --git a/live-build/apparmor/5.15/query/label/perms b/live-build/apparmor/5.15/query/label/perms new file mode 100644 index 00000000..71685cbf --- /dev/null +++ b/live-build/apparmor/5.15/query/label/perms @@ -0,0 +1 @@ +allow deny audit quiet diff --git a/live-build/apparmor/5.15/rlimit/mask b/live-build/apparmor/5.15/rlimit/mask new file mode 100644 index 00000000..c305a7d2 --- /dev/null +++ b/live-build/apparmor/5.15/rlimit/mask @@ -0,0 +1 @@ +cpu fsize data stack core rss nproc nofile memlock as locks sigpending msgqueue nice rtprio rttime diff --git a/live-build/apparmor/5.15/signal/mask b/live-build/apparmor/5.15/signal/mask new file mode 100644 index 00000000..9eb55a04 --- /dev/null +++ b/live-build/apparmor/5.15/signal/mask @@ -0,0 +1 @@ +hup int quit ill trap abrt bus fpe kill usr1 segv usr2 pipe alrm term stkflt chld cont stop stp ttin ttou urg xcpu xfsz vtalrm prof winch io pwr sys emt lost From e4fa9ef18d40f37ea5e1706982fa888f4507f398 Mon Sep 17 00:00:00 2001 From: Catherine Redfield Date: Thu, 8 Feb 2024 22:22:04 -0500 Subject: [PATCH 2/3] feat(apparmor): Add kernel apparmor check to snap validation (LP: #2052789) For jammy and later, snap validation verifies that the kernel version matches the livecd-rootfs version, if available. This change bring focal in line with that paradigm. This is necessary due to the linux-$CLOUD-5.15 kernels requiring a different apparmor feature set that generic. (cherry picked from commit b2f25256707373537ce6c6f37fa5d456f1958edc) --- live-build/functions | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/live-build/functions b/live-build/functions index fa9bcda6..ca09e81e 100644 --- a/live-build/functions +++ b/live-build/functions @@ -726,13 +726,44 @@ snap_preseed() { snap_validate_seed() { local CHROOT_ROOT=$1 - + local kern_major_min=undefined + local boot_filename=undefined + + # ppc64el still uses /boot/vmlinux so we need to determine the boot file name as non ppc64el use /boot/vmlinuz + # We don't need to query the arch as we can use existence of the file to determine the boot file name. Both + # will never be present at the same time. + if [ -e ${CHROOT_ROOT}/boot/vmlinuz ]; then + boot_filename=vmlinuz + elif [ -e ${CHROOT_ROOT}/boot/vmlinux ]; then + boot_filename=vmlinux + fi + if [ ${boot_filename} != undefined ]; then # we have a known boot file so we can proceed with checking for features to mount + kern_major_min=$(readlink --canonicalize --no-newline ${CHROOT_ROOT}/boot/${boot_filename} | grep --extended-regexp --only-matching --max-count 1 '[0-9]+\.[0-9]+') + if [ -d /usr/share/livecd-rootfs/live-build/apparmor/${kern_major_min} ]; then + # if an Ubuntu version has different kernel apparmor features between LTS and HWE kernels + # a snap pre-seeding issue can occur, where the incorrect apparmor features are reported + # basic copy of a directory structure overriding the "generic" feature set + # which is tied to the LTS kernel + + # Bind kernel apparmor directory to feature directory for snap preseeding + umount "${CHROOT_ROOT}/sys/kernel/security/apparmor/features/" + mount --bind /usr/share/livecd-rootfs/live-build/apparmor/${kern_major_min} "${CHROOT_ROOT}/sys/kernel/security/apparmor/features/" + fi + fi + if [ -e "${CHROOT_ROOT}/var/lib/snapd/seed/seed.yaml" ]; then snap debug validate-seed "${CHROOT_ROOT}/var/lib/snapd/seed/seed.yaml" /usr/lib/snapd/snap-preseed --reset $(realpath "${CHROOT_ROOT}") /usr/lib/snapd/snap-preseed $(realpath "${CHROOT_ROOT}") chroot "${CHROOT_ROOT}" apparmor_parser --skip-read-cache --write-cache --skip-kernel-load --verbose -j `nproc` /etc/apparmor.d fi + + # Unmount kernel specific apparmor feature + # mount generic apparmor feature again (cleanup) + if [ -d /build/config/hooks.d/extra/apparmor/${kern_major_min} ]; then + umount "${CHROOT_ROOT}/sys/kernel/security/apparmor/features/" + mount -o bind /usr/share/livecd-rootfs/live-build/apparmor/generic "${CHROOT_ROOT}/sys/kernel/security/apparmor/features/" + fi } snap_from_seed() { From e51e89423d7551d1db82f3bd869867aa7eabb1a5 Mon Sep 17 00:00:00 2001 From: Philip Roche Date: Fri, 9 Feb 2024 10:15:49 +0000 Subject: [PATCH 3/3] Update d/ch for 2.664.53 release --- debian/changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/debian/changelog b/debian/changelog index c4c2e3fd..a62bc8de 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +livecd-rootfs (2.664.53) UNRELEASED; urgency=medium + + [Catherine Redfield] + * add 5.15 apparmor directory for snap preseeding with 5.15 kernel (LP: #2052789) + + -- Phil Roche Fri, 09 Feb 2024 09:41:18 +0000 + livecd-rootfs (2.664.52) focal; urgency=medium * fix: use correct sshd_config.d/ ordering. (LP: #2049860)