Fix some issues due to IMA related changes
v2 cover Fix some issues due to IMA related changes
This patchset removes a kernel patch related to overlayfs and IMA appraisal file change notifictions and a squashfs xattr kernel config option. Further, it fixes the do_configure function and renames linux-%.bbappend to linux-yocto%.bbappend to avoid side-effects in build targets unrelated to the Linux kernel, such as kernel-firmware.
Stefan
Stefan Berger (4):
linux: overlayfs: Drop kernel patch resolving a file change
notification issue
ima: Drop kernel config option CONFIG_SQUASHFS_XATTR=y from ima.cfg
integrity: Fix the do_configure function
integrity: Rename linux-%.bbappend to linux-yocto%.bbappend
...linux-%.bbappend => linux-yocto%.bbappend} | 0
...Increment-iversion-upon-file-changes.patch | 42 -------------------
.../recipes-kernel/linux/linux/ima.cfg | 1 -
.../recipes-kernel/linux/linux_ima.inc | 7 ++--
4 files changed, 4 insertions(+), 46 deletions(-)
rename meta-integrity/recipes-kernel/linux/{linux-%.bbappend => linux-yocto%.bbappend} (100%)
delete mode 100644 meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patchSignature · 1 line
2.34.1
PATCH v2 1/4 linux: overlayfs: Drop kernel patch resolving a file change notification issue
Revert the patch resolving a file change notitfication issue (for IMA appraisal) since this patch fails in 'many downstream kernels'.
- https://lists.yoctoproject.org/g/yocto/message/59928
- https://lists.yoctoproject.org/g/yocto/message/59929
--- ...Increment-iversion-upon-file-changes.patch | 42 ------------------- .../recipes-kernel/linux/linux_ima.inc | 1 - 2 files changed, 43 deletions(-) delete mode 100644 meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch deleted +0 -42
@@ -1,42 +0,0 @@ -From e9ed62e8d1d3eee7ffe862d9812c5320d3b9bd88 Mon Sep 17 00:00:00 2001 -From: Stefan Berger <[email protected]> -Date: Thu, 6 Apr 2023 11:27:29 -0400 -Subject: [PATCH] ovl: Increment iversion upon file changes - -This is a temporary patch for kernels that do not implement -STATX_CHANGE_COOKIE (<= 6.2). The successor patch will be this one: - -https://lore.kernel.org/linux-integrity/20230418-engste-gastwirtschaft-601fb389bba5@brauner/T/#m3bf84296fe9e6499abb6e3191693948add2ff459 - -Increment the lower inode's iversion for IMA to be able to recognize -changes to the file. - -Signed-off-by: Stefan Berger <[email protected]> ---- - fs/overlayfs/file.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c -index 6011f955436b..1dfe5e7bfe1c 100644 ---- a/fs/overlayfs/file.c -+++ b/fs/overlayfs/file.c -@@ -13,6 +13,7 @@ - #include <linux/security.h> - #include <linux/mm.h> - #include <linux/fs.h> -+#include <linux/iversion.h> - #include "overlayfs.h" - - struct ovl_aio_req { -@@ -408,6 +409,8 @@ static ssize_t ovl_write_iter(struct kiocb *iocb, struct iov_iter *iter) - if (ret != -EIOCBQUEUED) - ovl_aio_cleanup_handler(aio_req); - } -+ if (ret > 0) -+ inode_maybe_inc_iversion(inode, false); - out: - revert_creds(old_cred); - out_fdput: --- -2.34.1 -
meta-integrity/recipes-kernel/linux/linux_ima.inc +0 -1
@@ -2,7 +2,6 @@ FILESEXTRAPATHS:append := "${THISDIR}/linux:" SRC_URI += " \ ${@bb.utils.contains('DISTRO_FEATURES', 'ima', 'file://ima.scc', '', d)} \ - file://0001-ovl-Increment-iversion-upon-file-changes.patch \ " do_configure() {
Signature · 1 line
2.34.1
PATCH v2 2/4 ima: Drop kernel config option CONFIG_SQUASHFS_XATTR=y from ima.cfg
In reply to Stefan BergerDrop the kernel config option CONFIG_SQUASHFS_XATTR=y from ima.cfg. Instead, require projects that use squashfs to set this option.
--- meta-integrity/recipes-kernel/linux/linux/ima.cfg | 1 - 1 file changed, 1 deletion(-)
meta-integrity/recipes-kernel/linux/linux/ima.cfg +0 -1
@@ -1,4 +1,3 @@ -CONFIG_SQUASHFS_XATTR=y CONFIG_KEYS=y CONFIG_ASYMMETRIC_KEY_TYPE=y CONFIG_SYSTEM_TRUSTED_KEYRING=y
Signature · 1 line
2.34.1
PATCH v2 3/4 integrity: Fix the do_configure function
In reply to Stefan BergerAppend ':append' to do_configure so it does not replace all existing do_configure's.
Only run 'sed' when DISTRO_FEATURES contains 'ima' and the .config file exists.
--- meta-integrity/recipes-kernel/linux/linux_ima.inc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
meta-integrity/recipes-kernel/linux/linux_ima.inc +4 -2
@@ -4,8 +4,10 @@ SRC_URI += " \ ${@bb.utils.contains('DISTRO_FEATURES', 'ima', 'file://ima.scc', '', d)} \ " -do_configure() { - sed -i "s|^CONFIG_SYSTEM_TRUSTED_KEYS=.*|CONFIG_SYSTEM_TRUSTED_KEYS=\"${IMA_EVM_ROOT_CA}\"|" .config +do_configure:append() { + if [ "${@bb.utils.contains('DISTRO_FEATURES', 'ima', 'yes', '', d)}" = "yes" ] && [ -f .config ] ; then + sed -i "s|^CONFIG_SYSTEM_TRUSTED_KEYS=.*|CONFIG_SYSTEM_TRUSTED_KEYS=\"${IMA_EVM_ROOT_CA}\"|" .config + fi } KERNEL_FEATURES:append = " ${@bb.utils.contains('DISTRO_FEATURES', 'modsign', ' features/ima/modsign.scc', '', d)}"
Signature · 1 line
2.34.1
PATCH v2 4/4 integrity: Rename linux-%.bbappend to linux-yocto%.bbappend
In reply to Stefan BergerTo avoid having linux-%.bbappend included in targets unrelated to the linux kernel, rename linux-%.bbappend to linux-yocto%.bbappend.
---
.../linux/{linux-%.bbappend => linux-yocto%.bbappend} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename meta-integrity/recipes-kernel/linux/{linux-%.bbappend => linux-yocto%.bbappend} (100%)meta-integrity/recipes-kernel/linux/linux-yocto%.bbappend renamed from meta-integrity/recipes-kernel/linux/linux-%.bbappend +0 -0
Signature · 1 line
2.34.1
Quoted 5 lines · Stefan Berger
This patchset removes a kernel patch related to overlayfs and IMA appraisal file change notifictions and a squashfs xattr kernel config option. Further, it fixes the
do_configurefunction and renames linux-%.bbappend to linux-yocto%.bbappend to avoid side-effects in build targets unrelated to the Linux kernel, such as kernel-firmware.
Thanks for the updates.
Locally this builds fine. OEQA runtime test pass and so does the yocto-check-layer. I am currently build on my CI for other Arches. Once I get a clean build I will merge to master.
BR,
Armin
Quoted 18 lines
Stefan
Stefan Berger (4):
linux: overlayfs: Drop kernel patch resolving a file change
notification issue
ima: Drop kernel config optionCONFIG_SQUASHFS_XATTR=yfrom ima.cfg
integrity: Fix thedo_configurefunction
integrity: Rename linux-%.bbappend to linux-yocto%.bbappend...linux-%.bbappend => linux-yocto%.bbappend} | 0 ...Increment-iversion-upon-file-changes.patch | 42 ------------------- .../recipes-kernel/linux/linux/ima.cfg | 1 - .../recipes-kernel/linux/linux_ima.inc | 7 ++-- 4 files changed, 4 insertions(+), 46 deletions(-)rename meta-integrity/recipes-kernel/linux/{linux-%.bbappend => linux-yocto%.bbappend} (100%) delete mode 100644
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch
Quoted 7 lines · Stefan Berger
This patchset removes a kernel patch related to overlayfs and IMA appraisal file change notifictions and a squashfs xattr kernel config option. Further, it fixes the
do_configurefunction and renames linux-%.bbappend to linux-yocto%.bbappend to avoid side-effects in build targets unrelated to the Linux kernel, such as kernel-firmware.Stefan
Merged.
thanks
Quoted 15 lines
Stefan Berger (4):
linux: overlayfs: Drop kernel patch resolving a file change
notification issue
ima: Drop kernel config optionCONFIG_SQUASHFS_XATTR=yfrom ima.cfg
integrity: Fix thedo_configurefunction
integrity: Rename linux-%.bbappend to linux-yocto%.bbappend...linux-%.bbappend => linux-yocto%.bbappend} | 0 ...Increment-iversion-upon-file-changes.patch | 42 ------------------- .../recipes-kernel/linux/linux/ima.cfg | 1 - .../recipes-kernel/linux/linux_ima.inc | 7 ++-- 4 files changed, 4 insertions(+), 46 deletions(-)rename meta-integrity/recipes-kernel/linux/{linux-%.bbappend => linux-yocto%.bbappend} (100%) delete mode 100644
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch