Fix IMA and EVM support
cover Fix IMA and EVM support
This series of patches fixes the current support for IMA and EVM by removing outdated patches for example and adding kernel config options. I have tried out these patches with OpenBMC where the appraisal policy now enforces signed executables and libraries.
Stefan
Stefan Berger (8):
ima: Document and replace keys and adapt scripts for EC keys
ima: Fix the ima_policy_appraise_all to appraise executables &
libraries
ima: Fix the IMA kernel feature
ima: Rename IMA_EVM_POLICY_SYSTEMD to IMA_EVM_POLICY
ima: Sign all executables and the ima-policy in the root filesystem
integrity: Update the README for IMA support
linux: overlayfs: Add kernel patch resolving a file change
notification issue
ima-evm-utils: Update ima-evm-utils to v1.5 and add a patch
meta-integrity/README.md | 22 +--
meta-integrity/classes/ima-evm-rootfs.bbclass | 34 ++++-
meta-integrity/data/debug-keys/README.md | 17 +++
.../data/debug-keys/ima-local-ca.pem | 15 ++
.../data/debug-keys/ima-local-ca.priv | 7 +
.../data/debug-keys/privkey_ima.pem | 17 +--
meta-integrity/data/debug-keys/x509_ima.der | Bin 707 -> 620 bytes
.../0001-ima-fix-ima_inode_post_setattr.patch | 51 -------
...Increment-iversion-upon-file-changes.patch | 42 ++++++
...for-creating-files-using-the-mknodat.patch | 138 ------------------
...-file-hash-setting-by-user-to-fix-an.patch | 60 --------
.../recipes-kernel/linux/linux/ima.cfg | 46 ++++++
.../recipes-kernel/linux/linux/ima.scc | 4 +
.../recipes-kernel/linux/linux_ima.inc | 11 +-
...ation-using-ioctl-when-evm_portable-.patch | 35 +++++
...-evm-utils_1.4.bb => ima-evm-utils_1.5.bb} | 9 +-
.../files/ima_policy_appraise_all | 9 +-
meta-integrity/scripts/ima-gen-CA-signed.sh | 9 +-
meta-integrity/scripts/ima-gen-local-ca.sh | 6 +-
meta-integrity/scripts/ima-gen-self-signed.sh | 41 ------
20 files changed, 240 insertions(+), 333 deletions(-)
create mode 100644 meta-integrity/data/debug-keys/README.md
create mode 100644 meta-integrity/data/debug-keys/ima-local-ca.pem
create mode 100644 meta-integrity/data/debug-keys/ima-local-ca.priv
delete mode 100644 meta-integrity/recipes-kernel/linux/linux/0001-ima-fix-ima_inode_post_setattr.patch
create mode 100644 meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch
delete mode 100644 meta-integrity/recipes-kernel/linux/linux/0002-ima-add-support-for-creating-files-using-the-mknodat.patch
delete mode 100644 meta-integrity/recipes-kernel/linux/linux/Revert-ima-limit-file-hash-setting-by-user-to-fix-an.patch
create mode 100644 meta-integrity/recipes-kernel/linux/linux/ima.cfg
create mode 100644 meta-integrity/recipes-kernel/linux/linux/ima.scc
create mode 100644 meta-integrity/recipes-security/ima-evm-utils/ima-evm-utils/0001-Do-not-get-generation-using-ioctl-when-evm_portable-.patch
rename meta-integrity/recipes-security/ima-evm-utils/{ima-evm-utils_1.4.bb => ima-evm-utils_1.5.bb} (71%)
delete mode 100755 meta-integrity/scripts/ima-gen-self-signed.shSignature · 1 line
2.34.1
PATCH 1/8 ima: Document and replace keys and adapt scripts for EC keys
For shorted file signatures use EC keys rather than RSA keys. Document the debug keys and their purpose.
Adapt the scripts for creating these types of keys to now create EC keys.
--- meta-integrity/data/debug-keys/README.md | 17 ++++++++ .../data/debug-keys/ima-local-ca.pem | 15 +++++++ .../data/debug-keys/ima-local-ca.priv | 7 +++ .../data/debug-keys/privkey_ima.pem | 17 ++------ meta-integrity/data/debug-keys/x509_ima.der | Bin 707 -> 620 bytes meta-integrity/scripts/ima-gen-CA-signed.sh | 9 ++-- meta-integrity/scripts/ima-gen-local-ca.sh | 6 +-- meta-integrity/scripts/ima-gen-self-signed.sh | 41 ------------------ 8 files changed, 50 insertions(+), 62 deletions(-) create mode 100644 meta-integrity/data/debug-keys/README.md create mode 100644 meta-integrity/data/debug-keys/ima-local-ca.pem create mode 100644 meta-integrity/data/debug-keys/ima-local-ca.priv delete mode 100755 meta-integrity/scripts/ima-gen-self-signed.sh
meta-integrity/data/debug-keys/README.md new file +17 -0
@@ -0,0 +1,17 @@ +# EVM & IMA keys + +The following IMA & EVM debug/test keys are in this directory + +- ima-local-ca.priv: The CA's private key (password: 1234) +- ima-local-ca.pem: The CA's self-signed certificate +- privkey_ima.pem: IMA & EVM private key used for signing files +- x509_ima.der: Certificate containing public key (of privkey_ima.pem) to verify signatures + +The CA's (self-signed) certificate can be used to verify the validity of +the x509_ima.der certificate. Since the CA certificate will be built into +the Linux kernel, any key (x509_ima.der) loaded onto the .ima keyring must +pass this test: + +``` + openssl verify -CAfile ima-local-ca.pem x509_ima.der +````
meta-integrity/data/debug-keys/ima-local-ca.pem new file +15 -0
@@ -0,0 +1,15 @@ +-----BEGIN CERTIFICATE----- +MIICWzCCAgCgAwIBAgITYMKT7/z5qI+hLfNC6Jy6hhBCWDAKBggqhkjOPQQDAjB9 +MRQwEgYDVQQKDAtleGFtcGxlLmNvbTFAMD4GA1UEAww3bWV0YS1pbnRlbC1pb3Qt +c2VjdXJpdHkgZXhhbXBsZSBjZXJ0aWZpY2F0ZSBzaWduaW5nIGtleTEjMCEGCSqG +SIb3DQEJARYUam9obi5kb2VAZXhhbXBsZS5jb20wIBcNMjMwNDI2MTYyNjExWhgP +MjEyMzA0MDIxNjI2MTFaMH0xFDASBgNVBAoMC2V4YW1wbGUuY29tMUAwPgYDVQQD +DDdtZXRhLWludGVsLWlvdC1zZWN1cml0eSBleGFtcGxlIGNlcnRpZmljYXRlIHNp +Z25pbmcga2V5MSMwIQYJKoZIhvcNAQkBFhRqb2huLmRvZUBleGFtcGxlLmNvbTBZ +MBMGByqGSM49AgEGCCqGSM49AwEHA0IABCiC+YIbCoOhyLy63lOGbiK+DPkW7gMU +rmfVLIb4oTmKxZS5/L8VE6hjKDcLa7OauyuW2nd4fnFAautFxpw/Q0yjXTBbMAwG +A1UdEwQFMAMBAf8wHQYDVR0OBBYEFL/PiFFjjlzVtExXMb2uXOfIgeIEMB8GA1Ud +IwQYMBaAFL/PiFFjjlzVtExXMb2uXOfIgeIEMAsGA1UdDwQEAwIBBjAKBggqhkjO +PQQDAgNJADBGAiEA0HOxloLMr87yDoH3CljWDWb7M2zLA+BQFXLN511qDl0CIQDu +clewWaJHw4Wq8IN3JsrNDDw2GfrN3sx4hfWUK/0SPw== +-----END CERTIFICATE-----
meta-integrity/data/debug-keys/ima-local-ca.priv new file +7 -0
@@ -0,0 +1,7 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIHjME4GCSqGSIb3DQEFDTBBMCkGCSqGSIb3DQEFDDAcBAhinM5KnV2x5wICCAAw +DAYIKoZIhvcNAgkFADAUBggqhkiG9w0DBwQI4Xbw/W1pgH0EgZCiurgCTUEIDbiK +x5kw3/Rg1/ZLwk5TEiMoIa9CmXEyuSRUla/Ta4o/rZEzKAp6vwkcupviirtWYems +lZNfggfzITWNEWtkU6BrhZgJ7kaeZrIbuAO7YUJy6Z2MQfgaKI9BE2EEgKJ+X5gY +LjkobSAtEqDjuheLgaXIMQ7/qT0MGmi6LmzwMEhu8ZXlNGg8udw= +-----END ENCRYPTED PRIVATE KEY-----
meta-integrity/data/debug-keys/privkey_ima.pem +3 -14
@@ -1,16 +1,5 @@ -----BEGIN PRIVATE KEY----- -MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAJw2G3d0fM36rcQU -Bt8V/SapJe0lxWJ+CY+HcMx8AhWY9XQ66AXcqBsRHiUnYCaFGXFI35VKGC6d/Gs6 -IWlHgI0tcTyzy5eul+BKRLy/3PNjkK2jJETlbetQy+gE6gUtg4RmPV5ALGksK74p -OrAfKnahoMi82NVIiBitwmRimms1AgMBAAECgYBTxciRFU1hAVBy2PKebKJoO0n1 -lc329fSWnmHlp5NOlcr8XCLWEfGtIk7ySd2MitCMKjKNU0EIrv0RXAlS9l9/gBYW -HY+eEaa6l80sp8q4aPKImSi0pb3LVNqWKXJg8qr4AZ45/TEL/fzILFv5QcY8xDjV -aj6DOlEnNDjlBlBbQQJBAMyYDlKItes/Rnmtp9roXj3XUfiBDHTLY2HVgDBe87sA -TOSnbgIv+6urd1h9XvBmJlRYH7YKJmBSZWcSlfdC6XkCQQDDdfkUMxQZo9PC/Eue -WYzytx4xUm3ItWcuKILtFgcNh3c4s4dMx4X/WhQj5/H/nVOIWDioQ0mrW3ap/qcb -SBydAkAf/gb/UPFhf9t9W3JMANn7wZfHzCYufT9lJQWOisqCC2H6v1Osc+Rey8k1 -xST7Yn3L4pvS03N8zGWe4IEi0QvBAkAWdTWbNos2rvYjzy05Enz5XkTf0eK/Tuh+ -CzWP3BoPWeM+5pHDJqGkx0rNHVdW0VLJtak83A5Y2/d0bMfygISZAkBFGui4HW+Q -1BlpmDeslsE11wm5jSmm6Ti12a2dVKGFo9QLQcSj4bfgxtqU2dQaYRmajXtSBrGQ -3vVaxg2EfqB1 +MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgmbPxV5LYZ530IfGm +SMpfPQFgoIkKPMRuNWLyVn+wiAOhRANCAAQ31W5ZQZdcwidgpyls2oO5rSsHLlqj +cKYaDF2fveMN5L/wBwEi84ubzz2+MkM9q7RaOSC4TPYHnhVvYcH+SsFv -----END PRIVATE KEY-----
meta-integrity/data/debug-keys/x509_ima.der binary +0 -0
meta-integrity/scripts/ima-gen-CA-signed.sh +5 -4
@@ -20,7 +20,6 @@ CAKEY=${2:-ima-local-ca.priv} cat << __EOF__ >$GENKEY [ req ] -default_bits = 1024 distinguished_name = req_distinguished_name prompt = no string_mask = utf8only
@@ -36,13 +35,15 @@ basicConstraints=critical,CA:FALSE #basicConstraints=CA:FALSE keyUsage=digitalSignature #keyUsage = nonRepudiation, digitalSignature, keyEncipherment +extendedKeyUsage=critical,codeSigning subjectKeyIdentifier=hash authorityKeyIdentifier=keyid #authorityKeyIdentifier=keyid,issuer __EOF__ -openssl req -new -nodes -utf8 -sha1 -days 365 -batch -config $GENKEY \ - -out csr_ima.pem -keyout privkey_ima.pem -openssl x509 -req -in csr_ima.pem -days 365 -extfile $GENKEY -extensions v3_usr \ +openssl req -new -nodes -utf8 -sha256 -days 36500 -batch -config $GENKEY \ + -out csr_ima.pem -keyout privkey_ima.pem \ + -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 +openssl x509 -req -in csr_ima.pem -days 36500 -extfile $GENKEY -extensions v3_usr \ -CA $CA -CAkey $CAKEY -CAcreateserial \ -outform DER -out x509_ima.der
meta-integrity/scripts/ima-gen-local-ca.sh +3 -3
@@ -18,7 +18,6 @@ GENKEY=ima-local-ca.genkey cat << __EOF__ >$GENKEY [ req ] -default_bits = 2048 distinguished_name = req_distinguished_name prompt = no string_mask = utf8only
@@ -33,10 +32,11 @@ emailAddress = [email protected] basicConstraints=CA:TRUE subjectKeyIdentifier=hash authorityKeyIdentifier=keyid:always,issuer -# keyUsage = cRLSign, keyCertSign +keyUsage = cRLSign, keyCertSign __EOF__ -openssl req -new -x509 -utf8 -sha1 -days 3650 -batch -config $GENKEY \ +openssl req -new -x509 -utf8 -sha256 -days 36500 -batch -config $GENKEY \ + -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 \ -outform DER -out ima-local-ca.x509 -keyout ima-local-ca.priv openssl x509 -inform DER -in ima-local-ca.x509 -out ima-local-ca.pem
meta-integrity/scripts/ima-gen-self-signed.sh deleted +0 -41
41 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 2/8 ima: Fix the ima_policy_appraise_all to appraise executables & libraries
In reply to Stefan BergerFix the ima_policy_appraise_all policy to appraise all executables and libraries. Also update the list of files that are not appraised to not appraise cgroup related files.
--- .../files/ima_policy_appraise_all | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
meta-integrity/recipes-security/ima_policy_appraise_all/files/ima_policy_appraise_all +8 -1
@@ -25,5 +25,12 @@ dont_appraise fsmagic=0xf97cff8c dont_appraise fsmagic=0x6e736673 # EFIVARFS_MAGIC dont_appraise fsmagic=0xde5e81e4 +# Cgroup +dont_appraise fsmagic=0x27e0eb +# Cgroup2 +dont_appraise fsmagic=0x63677270 -appraise +# Appraise libraries +appraise func=MMAP_CHECK mask=MAY_EXEC +# Appraise executables +appraise func=BPRM_CHECK
Signature · 1 line
2.34.1
PATCH 3/8 ima: Fix the IMA kernel feature
In reply to Stefan BergerFix the IMA kernel feature. Remove outdated patches and add ima.cfg holding kernel configuration options for IMA and EVM.
--- meta-integrity/classes/ima-evm-rootfs.bbclass | 5 +- .../0001-ima-fix-ima_inode_post_setattr.patch | 51 ------- ...for-creating-files-using-the-mknodat.patch | 138 ------------------ ...-file-hash-setting-by-user-to-fix-an.patch | 60 -------- .../recipes-kernel/linux/linux/ima.cfg | 46 ++++++ .../recipes-kernel/linux/linux/ima.scc | 4 + .../recipes-kernel/linux/linux_ima.inc | 10 +- 7 files changed, 63 insertions(+), 251 deletions(-) delete mode 100644 meta-integrity/recipes-kernel/linux/linux/0001-ima-fix-ima_inode_post_setattr.patch delete mode 100644 meta-integrity/recipes-kernel/linux/linux/0002-ima-add-support-for-creating-files-using-the-mknodat.patch delete mode 100644 meta-integrity/recipes-kernel/linux/linux/Revert-ima-limit-file-hash-setting-by-user-to-fix-an.patch create mode 100644 meta-integrity/recipes-kernel/linux/linux/ima.cfg create mode 100644 meta-integrity/recipes-kernel/linux/linux/ima.scc
meta-integrity/classes/ima-evm-rootfs.bbclass +4 -1
@@ -17,7 +17,7 @@ IMA_EVM_X509 ?= "${IMA_EVM_KEY_DIR}/x509_ima.der" # with a .x509 suffix. See linux-%.bbappend for details. # # ima-local-ca.x509 is what ima-gen-local-ca.sh creates. -IMA_EVM_ROOT_CA ?= "" +IMA_EVM_ROOT_CA ?= "${IMA_EVM_KEY_DIR}/ima-local-ca.pem" # Sign all regular files by default. IMA_EVM_ROOTFS_SIGNED ?= ". -type f"
@@ -31,6 +31,9 @@ IMA_EVM_ROOTFS_IVERSION ?= "" # Avoid re-generating fstab when ima is enabled. WIC_CREATE_EXTRA_ARGS:append = "${@bb.utils.contains('DISTRO_FEATURES', 'ima', ' --no-fstab-update', '', d)}" +# Add necessary tools (e.g., keyctl) to image +IMAGE_INSTALL:append = "${@bb.utils.contains('DISTRO_FEATURES', 'ima', ' ima-evm-utils', '', d)}" + ima_evm_sign_rootfs () { cd ${IMAGE_ROOTFS}
meta-integrity/recipes-kernel/linux/linux/0001-ima-fix-ima_inode_post_setattr.patch deleted +0 -51
51 lines not on this page · raw message
meta-integrity/recipes-kernel/linux/linux/0002-ima-add-support-for-creating-files-using-the-mknodat.patch deleted +0 -138
138 lines not on this page · raw message
meta-integrity/recipes-kernel/linux/linux/Revert-ima-limit-file-hash-setting-by-user-to-fix-an.patch deleted +0 -60
60 lines not on this page · raw message
meta-integrity/recipes-kernel/linux/linux/ima.cfg new file +46 -0
46 lines not on this page · raw message
meta-integrity/recipes-kernel/linux/linux/ima.scc new file +4 -0
@@ -0,0 +1,4 @@ +define KFEATURE_DESCRIPTION "Enable IMA" + +kconf non-hardware ima.cfg +
meta-integrity/recipes-kernel/linux/linux_ima.inc +9 -1
@@ -1,4 +1,12 @@ -KERNEL_FEATURES:append = " ${@bb.utils.contains("DISTRO_FEATURES", "ima", " features/ima/ima.scc", "" ,d)}" +FILESEXTRAPATHS:append := "${THISDIR}/linux:" + +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 +} KERNEL_FEATURES:append = " ${@bb.utils.contains('DISTRO_FEATURES', 'modsign', ' features/ima/modsign.scc', '', d)}"
Signature · 1 line
2.34.1
PATCH 4/8 ima: Rename IMA_EVM_POLICY_SYSTEMD to IMA_EVM_POLICY
In reply to Stefan BergerThe IMA policy will be specified using the IMA_EVM_POLICY variable since systemd will not be involved in loading the policy but the init script will load it.
--- meta-integrity/README.md | 2 +- meta-integrity/classes/ima-evm-rootfs.bbclass | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
meta-integrity/README.md +1 -1
@@ -187,7 +187,7 @@ IMA policy loading became broken in systemd 2.18. The modified systemd changes. To activate policy loading via systemd, place a policy file in `/etc/ima/ima-policy`, for example with: - IMA_EVM_POLICY_SYSTEMD = "${INTEGRITY_BASE}/data/ima_policy_simple" + IMA_EVM_POLICY = "${INTEGRITY_BASE}/data/ima_policy_simple" To check that measuring works, look at `/sys/kernel/security/ima/ascii_runtime_measurements`
meta-integrity/classes/ima-evm-rootfs.bbclass +2 -2
@@ -69,10 +69,10 @@ ima_evm_sign_rootfs () { find ${IMA_EVM_ROOTFS_HASHED} | xargs -d "\n" --no-run-if-empty --verbose evmctl ima_hash # Optionally install custom policy for loading by systemd. - if [ "${IMA_EVM_POLICY_SYSTEMD}" ]; then + if [ "${IMA_EVM_POLICY}" ]; then install -d ./${sysconfdir}/ima rm -f ./${sysconfdir}/ima/ima-policy - install "${IMA_EVM_POLICY_SYSTEMD}" ./${sysconfdir}/ima/ima-policy + install "${IMA_EVM_POLICY}" ./${sysconfdir}/ima/ima-policy fi }
Signature · 1 line
2.34.1
PATCH 5/8 ima: Sign all executables and the ima-policy in the root filesystem
In reply to Stefan Berger--- meta-integrity/classes/ima-evm-rootfs.bbclass | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-)
meta-integrity/classes/ima-evm-rootfs.bbclass +20 -5
@@ -62,17 +62,32 @@ ima_evm_sign_rootfs () { perl -pi -e 's;(\S+)(\s+)(${@"|".join((d.getVar("IMA_EVM_ROOTFS_IVERSION", True) or "no-such-mount-point").split())})(\s+)(\S+)(\s+)(\S+);\1\2\3\4\5\6\7,iversion;; s/(,iversion)+/,iversion/;' etc/fstab fi - # Sign file with private IMA key. EVM not supported at the moment. - bbnote "IMA/EVM: signing files 'find ${IMA_EVM_ROOTFS_SIGNED}' with private key '${IMA_EVM_PRIVKEY}'" - find ${IMA_EVM_ROOTFS_SIGNED} | xargs -d "\n" --no-run-if-empty --verbose evmctl ima_sign --key ${IMA_EVM_PRIVKEY} - bbnote "IMA/EVM: hashing files 'find ${IMA_EVM_ROOTFS_HASHED}'" - find ${IMA_EVM_ROOTFS_HASHED} | xargs -d "\n" --no-run-if-empty --verbose evmctl ima_hash + # Detect 32bit target to pass --m32 to evmctl by looking at libc + tmp="$(file "${IMAGE_ROOTFS}/lib/libc.so.6" | grep -o 'ELF .*-bit')" + if [ "${tmp}" = "ELF 32-bit" ]; then + evmctl_param="--m32" + elif [ "${tmp}" = "ELF 64-bit" ]; then + evmctl_param="" + else + bberror "Unknown target architecture bitness: '${tmp}'" >&2 + exit 1 + fi + + bbnote "IMA/EVM: Signing root filesystem at ${IMAGE_ROOTFS} with key ${IMA_EVM_PRIVKEY}" + evmctl sign --imasig ${evmctl_param} --portable -a sha256 --key ${IMA_EVM_PRIVKEY} -r "${IMAGE_ROOTFS}" + + # check signing key and signature verification key + evmctl ima_verify ${evmctl_param} --key "${IMA_EVM_X509}" "${IMAGE_ROOTFS}/lib/libc.so.6" || exit 1 + evmctl verify ${evmctl_param} --key "${IMA_EVM_X509}" "${IMAGE_ROOTFS}/lib/libc.so.6" || exit 1 # Optionally install custom policy for loading by systemd. if [ "${IMA_EVM_POLICY}" ]; then install -d ./${sysconfdir}/ima rm -f ./${sysconfdir}/ima/ima-policy install "${IMA_EVM_POLICY}" ./${sysconfdir}/ima/ima-policy + + bbnote "IMA/EVM: Signing IMA policy with key ${IMA_EVM_PRIVKEY}" + evmctl sign --imasig ${evmctl_param} --portable -a sha256 --key "${IMA_EVM_PRIVKEY}" "${IMAGE_ROOTFS}/etc/ima/ima-policy" fi }
Signature · 1 line
2.34.1
PATCH 6/8 integrity: Update the README for IMA support
In reply to Stefan BergerUpdate the README describing how IMA support can be used.
--- meta-integrity/README.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
meta-integrity/README.md +11 -9
@@ -76,7 +76,7 @@ other layers needed. e.g.: It has some dependencies on a suitable BSP; in particular the kernel must have a recent enough IMA/EVM subsystem. The layer was tested with -Linux 3.19 and uses some features (like loading X509 certificates +Linux 6.1 and uses some features (like loading X509 certificates directly from the kernel) which were added in that release. Your mileage may vary with older kernels.
@@ -89,10 +89,17 @@ Adding the layer only enables IMA (see below regarding EVM) during compilation of the Linux kernel. To also activate it when building the image, enable image signing in the local.conf like this: + DISTRO_FEATURES:append = " integrity ima" + IMAGE_CLASSES += "ima-evm-rootfs" + IMA_EVM_KEY_DIR = "${INTEGRITY_BASE}/data/debug-keys" IMA_EVM_PRIVKEY = "${IMA_EVM_KEY_DIR}/privkey_ima.pem" IMA_EVM_X509 = "${IMA_EVM_KEY_DIR}/x509_ima.der" + IMA_EVM_ROOT_CA = "${IMA_EVM_KEY_DIR}/ima-local-ca.pem" + + # The following policy enforces IMA & EVM signatures + IMA_EVM_POLICY = "${INTEGRITY_BASE}/recipes-security/ima_policy_appraise_all/files/ima_policy_appraise_all" This uses the default keys provided in the "data" directory of the layer. Because everyone has access to these private keys, such an image
@@ -113,10 +120,7 @@ for that are included in the layer. This is also how the cd $IMA_EVM_KEY_DIR # In that shell, create the keys. Several options exist: - # 1. Self-signed keys. - $INTEGRITY_BASE/scripts/ima-gen-self-signed.sh - - # 2. Keys signed by a new CA. + # 1. Keys signed by a new CA. # When asked for a PEM passphrase, that will be for the root CA. # Signing images then will not require entering that passphrase, # only creating new certificates does. Most likely the default
@@ -125,13 +129,11 @@ for that are included in the layer. This is also how the # $INTEGRITY_BASE/scripts/ima-gen-local-ca.sh # $INTEGRITY_BASE/scripts/ima-gen-CA-signed.sh - # 3. Keys signed by an existing CA. + # 2. Keys signed by an existing CA. # $INTEGRITY_BASE/scripts/ima-gen-CA-signed.sh <CA.pem> <CA.priv> exit -When using ``ima-self-signed.sh`` as described above, self-signed keys -are created. Alternatively, one can also use keys signed by a CA. The -``ima-gen-local-ca.sh`` and ``ima-gen.sh`` scripts create a root CA +The ``ima-gen-local-ca.sh`` and ``ima-gen.sh`` scripts create a root CA and sign the signing keys with it. The ``ima-evm-rootfs.bbclass`` then supports adding tha CA's public key to the kernel's system keyring by compiling it directly into the kernel. Because it is unknown whether
Signature · 1 line
2.34.1
PATCH 7/8 linux: overlayfs: Add kernel patch resolving a file change notification issue
In reply to Stefan BergerAdd a temporary patch that resolves a file change notification issue with overlayfs where IMA did not become aware of the file changes since the 'lower' inode's i_version had not changed. The issue will be resolved in later kernels with the following patch that builds on newly addd feature (support for STATX_CHANGE_COOKIE) in v6.3-rc1:
--- ...Increment-iversion-upon-file-changes.patch | 42 +++++++++++++++++++ .../recipes-kernel/linux/linux_ima.inc | 1 + 2 files changed, 43 insertions(+) create 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 new file +42 -0
@@ -0,0 +1,42 @@ +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 +1 -0
@@ -2,6 +2,7 @@ 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
Re: [yocto] [meta-security][PATCH 7/8] linux: overlayfs: Add kernel patch resolving a file change notification issue
Hi,
Quoted 7 lines · Stefan Berger
Add a temporary patch that resolves a file change notification issue with overlayfs where IMA did not become aware of the file changes since the 'lower' inode's
i_versionhad not changed. The issue will be resolved in later kernels with the following patch that builds on newly addd feature (support forSTATX_CHANGE_COOKIE) in v6.3-rc1:
Would be nice to have Upstream-Status for each patch. I guess status would be Backport here.
Cheers,
-Mikko
Quoted 80 lines
Signed-off-by Stefan Berger <[email protected]>--- ...Increment-iversion-upon-file-changes.patch | 42 +++++++++++++++++++ .../recipes-kernel/linux/linux_ima.inc | 1 + 2 files changed, 43 insertions(+) create mode 100644 meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patchmeta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch new file +42
-0@@ -0,0 +1,42 @@ +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 +1
-0@@ -2,6 +2,7 @@ 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 · 11 lines
2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#59800): https://lists.yoctoproject.org/g/yocto/message/59800 Mute This Topic: https://lists.yoctoproject.org/mt/98557297/7159507 Group Owner: [email protected] Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
Re: [yocto] [meta-security][PATCH 7/8] linux: overlayfs: Add kernel patch resolving a file change notification issue
Quoted 9 lines · Mikko Rapeli
Hi,
Quoted 6 lines · Stefan Berger
Add a temporary patch that resolves a file change notification issue with overlayfs where IMA did not become aware of the file changes since the 'lower' inode's
i_versionhad not changed. The issue will be resolved in later kernels with the following patch that builds on newly addd feature (support forSTATX_CHANGE_COOKIE) in v6.3-rc1:
Quoted 4 lines
Would be nice to have Upstream-Status for each patch. I guess status would be Backport here.
It's quite possible that this series here https://lkml.org/lkml/2022/10/21/624
(alone?) would provide the infrastructure for STATX_CHANGE_COOKIE (introduced in 3/8) and have that referenced patch applied which isn't upstreamed so far, either.
For now this two-liner seemed simpler and resolves the issue. I understand the concern, though...
Stefan
Quoted 86 lines
Cheers,
-Mikko
Quoted 80 lines
Signed-off-by Stefan Berger <[email protected]>--- ...Increment-iversion-upon-file-changes.patch | 42 +++++++++++++++++++ .../recipes-kernel/linux/linux_ima.inc | 1 + 2 files changed, 43 insertions(+)create mode 100644
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patchmeta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch new file +42
-0@@ -0,0 +1,42 @@ +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 +1
-0@@ -2,6 +2,7 @@ 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 · 11 lines
2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#59800): https://lists.yoctoproject.org/g/yocto/message/59800 Mute This Topic: https://lists.yoctoproject.org/mt/98557297/7159507 Group Owner: [email protected] Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
Re: [yocto] [meta-security][PATCH 7/8] linux: overlayfs: Add kernel patch resolving a file change notification issue
Hi Stefan,
Having this patch applied unconditionally to all kernels doesn't work and the patch fails in many downstream kernels.
I suggest reverting this one if no other solutions come up.
Jose
Stefan Berger <[email protected]> escreveu no dia sexta, 28/04/2023 à(s) 13:55:
Quoted 130 lines · Mikko Rapeli
Quoted 10 lines
Hi,
Quoted 7 lines · Stefan Berger
Add a temporary patch that resolves a file change notification issue with overlayfs where IMA did not become aware of the file changes since the 'lower' inode's
i_versionhad not changed. The issue will be resolved in later kernels with the following patch that builds on newly addd feature (support forSTATX_CHANGE_COOKIE) in v6.3-rc1:Quoted 3 lines
Would be nice to have Upstream-Status for each patch. I guess status would be Backport here.
It's quite possible that this series here
https://lkml.org/lkml/2022/10/21/624
(alone? <https://lkml.org/lkml/2022/10/21/624(alone?>) would provide the infrastructure forSTATX_CHANGE_COOKIE(introduced in 3/8) and have that referenced patch applied which isn't upstreamed so far, either.For now this two-liner seemed simpler and resolves the issue. I understand the concern, though...
Stefan
Quoted 11 lines
Cheers,
-Mikko
Quoted 6 lines
Signed-off-by Stefan Berger <[email protected]>--- ...Increment-iversion-upon-file-changes.patch | 42 +++++++++++++++++++ .../recipes-kernel/linux/linux_ima.inc | 1 + 2 files changed, 43 insertions(+)create mode 100644
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patchQuoted 2 lines
Quoted 2 lines
diff --git
a/meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patchb/meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patchQuoted 4 lines
Quoted 4 lines
new file mode 100644
index 0000000..d2b5c28
---/dev/null
+++
b/meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patchQuoted 10 lines
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch line 9
Quoted 10 lines
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch new file +9
-0@@ -0,0 +1,42 @@ +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: + +Quoted 14 lines
Quoted 14 lines
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch new file +14
-0+ +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 @@Quoted 8 lines
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch
Quoted 8 lines
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch new file +8
-0+ #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)Quoted 4 lines
Quoted 4 lines
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch new file +4
-0+ if (ret != -EIOCBQUEUED) + ovl_aio_cleanup_handler(aio_req); + } ++ if (ret > 0)Quoted 8 lines
Review
Quoted 8 lines
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch new file +7
-0++ inode_maybe_inc_iversion(inode, false); + out: + revert_creds(old_cred); + out_fdput: +-- +2.34.1 +(quoted diff) +0
-0b/meta-integrity/recipes-kernel/linux/linux_ima.inc
Quoted 7 lines
meta-integrity/recipes-kernel/linux/linux_ima.inc FILESEXTRAPATHS:append := "${THISDIR}/linux:" · line 4
Quoted 7 lines
index 0b6f530..9d48e5c 100644
meta-integrity/recipes-kernel/linux/linux_ima.inc +0
-0@@ -2,6 +2,7 @@ FILESEXTRAPATHS:append := "${THISDIR}/linux:" SRC_URI += " \ ${@bb.utils.contains('DISTRO_FEATURES', 'ima', 'file://ima.scc','', d)} \
Quoted 12 lines
Quoted 11 lines
meta-integrity/recipes-kernel/linux/linux_ima.inc +1
-1+ file://0001-ovl-Increment-iversion-upon-file-changes.patch \ " do_configure() { --2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#59807):
https://lists.yoctoproject.org/g/yocto/message/59807
Mute This Topic: https://lists.yoctoproject.org/mt/98557297/5052612
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Signature · 3 lines
Best regards, José Quaresma
Re: [yocto] [meta-security][PATCH 7/8] linux: overlayfs: Add kernel patch resolving a file change notification issue
Quoted 4 lines · Jose Quaresma
Hi Stefan,
Having this patch applied unconditionally to all kernels doesn't work and the patch fails in many downstream kernels. I suggest reverting this one if no other solutions come up.
Then let me drop this one. I just posted v2 of this series and can repost in v3 with this patch dropped and possibly only have it applied in the OpenBMC project. I suppose my conclusion from OpenBMC, which currently works with a 6.1.15 kernel, that all other Yocto projects also now use a >= 6.1.15 kernel, was wrong?
Stefan
Quoted 125 lines
Jose
Stefan Berger <[email protected] <mailto:[email protected]>> escreveu no dia sexta, 28/04/2023 à(s) 13:55:
On 4/28/23 08:48, Mikko Rapeli wrote: > Hi, > > On Fri, Apr 28, 2023 at 08:23:15AM -0400, Stefan Berger wrote: >> Add a temporary patch that resolves a file change notification issue >> with overlayfs where IMA did not become aware of the file changes >> since the 'lower' inode's i_version had not changed. The issue will be >> resolved in later kernels with the following patch that builds on >> newly addd feature (support for STATX_CHANGE_COOKIE) in v6.3-rc1: >> >> https://lore.kernel.org/linux-integrity/20230418-engste-gastwirtschaft-601fb389bba5@brauner/T/#m3bf84296fe9e6499abb6e3191693948add2ff459 <https://lore.kernel.org/linux-integrity/20230418-engste-gastwirtschaft-601fb389bba5@brauner/T/#m3bf84296fe9e6499abb6e3191693948add2ff459> > > Would be nice to have Upstream-Status for each patch. I guess status > would be Backport here. It's quite possible that this series here https://lkml.org/lkml/2022/10/21/624 (alone? <https://lkml.org/lkml/2022/10/21/624(alone?>) would provide the infrastructure for STATX_CHANGE_COOKIE (introduced in 3/8) and have that referenced patch applied which isn't upstreamed so far, either. For now this two-liner seemed simpler and resolves the issue. I understand the concern, though... Stefan > > Cheers, > > -Mikko > >> Signed-off-by: Stefan Berger <[email protected] <mailto:[email protected]>> >> --- >> ...Increment-iversion-upon-file-changes.patch | 42 +++++++++++++++++++ >> .../recipes-kernel/linux/linux_ima.inc | 1 + >> 2 files changed, 43 insertions(+) >> create mode 100644 meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch >> >> diff --git a/meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch b/meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch >> new file mode 100644 >> index 0000000..d2b5c28 >> --- /dev/null >> +++ b/meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch >> @@ -0,0 +1,42 @@ >> +From e9ed62e8d1d3eee7ffe862d9812c5320d3b9bd88 Mon Sep 17 00:00:00 2001 >> +From: Stefan Berger <[email protected] <mailto:[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 <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] <mailto:[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 >> + >> diff --git a/meta-integrity/recipes-kernel/linux/linux_ima.inc b/meta-integrity/recipes-kernel/linux/linux_ima.inc >> index 0b6f530..9d48e5c 100644 >> --- a/meta-integrity/recipes-kernel/linux/linux_ima.inc >> +++ b/meta-integrity/recipes-kernel/linux/linux_ima.inc >> @@ -2,6 +2,7 @@ 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() { >> -- >> 2.34.1 >> > >> >> >> > -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#59807): https://lists.yoctoproject.org/g/yocto/message/59807 <https://lists.yoctoproject.org/g/yocto/message/59807> Mute This Topic: https://lists.yoctoproject.org/mt/98557297/5052612 <https://lists.yoctoproject.org/mt/98557297/5052612> Group Owner: [email protected] <mailto:yocto%[email protected]> Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub <https://lists.yoctoproject.org/g/yocto/unsub> [[email protected] <mailto:[email protected]>] -=-=-=-=-=-=-=-=-=-=-=-Signature · 3 lines
Best regards, José Quaresma
Re: [yocto] [meta-security][PATCH 7/8] linux: overlayfs: Add kernel patch resolving a file change notification issue
Stefan Berger <[email protected]> escreveu no dia terça, 9/05/2023 à(s) 17:21:
Quoted 7 lines · Jose Quaresma
Quoted 3 lines
Hi Stefan,
Having this patch applied unconditionally to all kernels doesn't work
and the patch fails in many downstream kernels.
Quoted 9 lines
Quoted 1 line
I suggest reverting this one if no other solutions come up.
Then let me drop this one. I just posted v2 of this series and can repost in v3 with this patch dropped and possibly
only have it applied in the OpenBMC project. I suppose my conclusion from OpenBMC, which currently works with a 6.1.15
kernel, that all other Yocto projects also now use a >= 6.1.15 kernel, was wrong?
yup! is also my opinion.
but after reverting this patch some other new issues comes up because the ima side effects changes
so linux-firmware dont build any more.
Jose
Quoted 164 lines
Stefan
Quoted 4 lines
Jose
Stefan Berger <[email protected] <mailto:[email protected]>>
escreveu no dia sexta, 28/04/2023 à(s) 13:55:
Quoted 8 lines · Mikko Rapeli
> Hi, > > On Fri, Apr 28, 2023 at 08:23:15AM -0400, Stefan Berger wrote: >> Add a temporary patch that resolves a file change notificationissue
Quoted 2 lines
>> with overlayfs where IMA did not become aware of the file changes >> since the 'lower' inode's
i_versionhad not changed. The issuewill be
Quoted 4 lines
>> resolved in later kernels with the following patch that builds on >> newly addd feature (support for
STATX_CHANGE_COOKIE) in v6.3-rc1:
>>
>>https://lore.kernel.org/linux-integrity/20230418-engste-gastwirtschaft-601fb389bba5@brauner/T/#m3bf84296fe9e6499abb6e3191693948add2ff459
<
https://lore.kernel.org/linux-integrity/20230418-engste-gastwirtschaft-601fb389bba5@brauner/T/#m3bf84296fe9e6499abb6e3191693948add2ff459Quoted 3 lines
>
> Would be nice to have Upstream-Status for each patch. I guessstatus
Quoted 3 lines
> would be Backport here.
It's quite possible that this series here
https://lkml.org/lkml/2022/10/21/624
Quoted 1 line
(alone? <https://lkml.org/lkml/2022/10/21/624(alone?>) wouldprovide the infrastructure for
STATX_CHANGE_COOKIE(introduced in 3/8)Quoted 1 line
and have that referenced patch applied which isn't upstreamed so
far, either.
Quoted 2 lines
For now this two-liner seemed simpler and resolves the issue. I
understand the concern, though...
Quoted 9 lines
Stefan > > Cheers, > > -Mikko > >> Signed-off-by: Stefan Berger <[email protected] <mailto:Quoted 2 lines
>> ---
>> ...Increment-iversion-upon-file-changes.patch | 42+++++++++++++++++++
Quoted 3 lines
>> .../recipes-kernel/linux/linux_ima.inc | 1 +>> 2 files changed, 43 insertions(+)
>> create mode 100644
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patchQuoted 2 lines
>> >> diff --git
a/meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patchb/meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patchQuoted 4 lines
>> new file mode 100644 >> index 0000000..d2b5c28 >> --- /dev/null >> +++
b/meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patchQuoted 2 lines
>> @@ -0,0 +1,42 @@ >> +From e9ed62e8d1d3eee7ffe862d9812c5320d3b9bd88 Mon Sep 1700:00:00 2001
Quoted 1 line
>> +From: Stefan Berger <[email protected] <mailto:
Quoted 5 lines
>> +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 thisone:
Quoted 2 lines
>> + >> +https://lore.kernel.org/linux-integrity/20230418-engste-gastwirtschaft-601fb389bba5@brauner/T/#m3bf84296fe9e6499abb6e3191693948add2ff459
<
https://lore.kernel.org/linux-integrity/20230418-engste-gastwirtschaft-601fb389bba5@brauner/T/#m3bf84296fe9e6499abb6e3191693948add2ff459Quoted 3 lines
>> +
>> +Increment the lower inode's iversion for IMA to be able torecognize
Quoted 3 lines
>> +changes to the file.
>> +
>> +Signed-off-by: Stefan Berger <[email protected] <mailto:Quoted 9 lines
>> +--- >> + 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 @@Quoted 8 lines
>> + #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)Quoted 4 lines
>> + if (ret != -EIOCBQUEUED) >> + ovl_aio_cleanup_handler(aio_req); >> + } >> ++ if (ret > 0)Quoted 8 lines
>> ++ inode_maybe_inc_iversion(inode, false); >> + out: >> + revert_creds(old_cred); >> + out_fdput: >> +-- >> +2.34.1 >> + >> diff --git a/meta-integrity/recipes-kernel/linux/linux_ima.incb/meta-integrity/recipes-kernel/linux/linux_ima.inc
Quoted 7 lines
>> index 0b6f530..9d48e5c 100644 >> --- a/meta-integrity/recipes-kernel/linux/linux_ima.inc >> +++ b/meta-integrity/recipes-kernel/linux/linux_ima.inc >> @@ -2,6 +2,7 @@ FILESEXTRAPATHS:append := "${THISDIR}/linux:" >> >> SRC_URI += " \ >> ${@bb.utils.contains('DISTRO_FEATURES', 'ima','file://ima.scc', '', d)} \
Quoted 8 lines
>> + file://0001-ovl-Increment-iversion-upon-file-changes.patch \ >> " >> >> do_configure() { >> -- >> 2.34.1 >> >Quoted 8 lines
>> >> >> > -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#59807):https://lists.yoctoproject.org/g/yocto/message/59807 <
https://lists.yoctoproject.org/g/yocto/message/59807>Quoted 1 line
Mute This Topic: https://lists.yoctoproject.org/mt/98557297/5052612<https://lists.yoctoproject.org/mt/98557297/5052612>
Quoted 1 line
Group Owner: [email protected] <mailto:
yocto%[email protected]>
Quoted 1 line
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub <
https://lists.yoctoproject.org/g/yocto/unsub> [[email protected] <mailto:[email protected]>]
Quoted 8 lines
-=-=-=-=-=-=-=-=-=-=-=---
Best regards,José Quaresma
Signature · 3 lines
Best regards, José Quaresma
Re: [yocto] [meta-security][PATCH 7/8] linux: overlayfs: Add kernel patch resolving a file change notification issue
Quoted 17 lines · Jose Quaresma
Stefan Berger <stefanb@ linux. ibm. com> escreveu no dia terça, 9/05/2023 à(s) 17: 21: On 5/9/23 10: 53, Jose Quaresma wrote: > Hi Stefan, > > Having this patch applied unconditionally to all kernels doesn't work and the patch ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
ZjQcmQRYFpfptBannerEndStefan Berger <[email protected] <mailto:[email protected]>> escreveu no dia terça, 9/05/2023 à(s) 17:21:
On 5/9/23 10:53, Jose Quaresma wrote:
> Hi Stefan,
>
> Having this patch applied unconditionally to all kernels doesn't work and the patch fails in many downstream kernels. > I suggest reverting this one if no other solutions come up.
Quoted 8 lines
Then let me drop this one. I just posted v2 of this series and can repost in v3 with this patch dropped and possibly only have it applied in the OpenBMC project. I suppose my conclusion from OpenBMC, which currently works with a 6.1.15 kernel, that all other Yocto projects also now use a >= 6.1.15 kernel, was wrong?
yup! is also my opinion.
but after reverting this patch some other new issues comes up because the ima side effects changes so linux-firmware dont build any more.
Can you either point me to the changes or tell me how you build linux-firmware so that I can recreate the issue locally?
Stefan
Quoted 142 lines
Jose
Stefan > > Jose > > Stefan Berger <[email protected] <mailto:[email protected]> <mailto:[email protected] <mailto:[email protected]>>> escreveu no dia sexta, 28/04/2023 à(s) 13:55: > > > > On 4/28/23 08:48, Mikko Rapeli wrote: > > Hi, > > > > On Fri, Apr 28, 2023 at 08:23:15AM -0400, Stefan Berger wrote: > >> Add a temporary patch that resolves a file change notification issue > >> with overlayfs where IMA did not become aware of the file changes > >> since the 'lower' inode's i_version had not changed. The issue will be > >> resolved in later kernels with the following patch that builds on > >> newly addd feature (support for STATX_CHANGE_COOKIE) in v6.3-rc1: > >> > >> https://lore.kernel.org/linux-integrity/20230418-engste-gastwirtschaft-601fb389bba5@brauner/T/#m3bf84296fe9e6499abb6e3191693948add2ff459 <https://lore.kernel.org/linux-integrity/20230418-engste-gastwirtschaft-601fb389bba5@brauner/T/#m3bf84296fe9e6499abb6e3191693948add2ff459> <https://lore.kernel.org/linux-integrity/20230418-engste-gastwirtschaft-601fb389bba5@brauner/T/#m3bf84296fe9e6499abb6e3191693948add2ff459 <https://lore.kernel.org/linux-integrity/20230418-engste-gastwirtschaft-601fb389bba5@brauner/T/#m3bf84296fe9e6499abb6e3191693948add2ff459>> > > > > Would be nice to have Upstream-Status for each patch. I guess status > > would be Backport here. > > It's quite possible that this series here https://lkml.org/lkml/2022/10/21/624 <https://lkml.org/lkml/2022/10/21/624> > (alone? <https://lkml.org/lkml/2022/10/21/624(alone <https://lkml.org/lkml/2022/10/21/624(alone>?>) would provide the infrastructure for STATX_CHANGE_COOKIE (introduced in 3/8) > and have that referenced patch applied which isn't upstreamed so far, either. > > For now this two-liner seemed simpler and resolves the issue. I understand the concern, though... > > Stefan > > > > > Cheers, > > > > -Mikko > > > >> Signed-off-by: Stefan Berger <[email protected] <mailto:[email protected]> <mailto:[email protected] <mailto:[email protected]>>> > >> --- > >> ...Increment-iversion-upon-file-changes.patch | 42 +++++++++++++++++++ > >> .../recipes-kernel/linux/linux_ima.inc | 1 + > >> 2 files changed, 43 insertions(+) > >> create mode 100644 meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch > >> > >> diff --git a/meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch b/meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch > >> new file mode 100644 > >> index 0000000..d2b5c28 > >> --- /dev/null > >> +++ b/meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch > >> @@ -0,0 +1,42 @@ > >> +From e9ed62e8d1d3eee7ffe862d9812c5320d3b9bd88 Mon Sep 17 00:00:00 2001 > >> +From: Stefan Berger <[email protected] <mailto:[email protected]> <mailto:[email protected] <mailto:[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 <https://lore.kernel.org/linux-integrity/20230418-engste-gastwirtschaft-601fb389bba5@brauner/T/#m3bf84296fe9e6499abb6e3191693948add2ff459> <https://lore.kernel.org/linux-integrity/20230418-engste-gastwirtschaft-601fb389bba5@brauner/T/#m3bf84296fe9e6499abb6e3191693948add2ff459 <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] <mailto:[email protected]> <mailto:[email protected] <mailto:[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 > >> + > >> diff --git a/meta-integrity/recipes-kernel/linux/linux_ima.inc b/meta-integrity/recipes-kernel/linux/linux_ima.inc > >> index 0b6f530..9d48e5c 100644 > >> --- a/meta-integrity/recipes-kernel/linux/linux_ima.inc > >> +++ b/meta-integrity/recipes-kernel/linux/linux_ima.inc > >> @@ -2,6 +2,7 @@ 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() { > >> -- > >> 2.34.1 > >> > > > >> > >> > >> > > > > > > > > -- > Best regards, > > José QuaresmaSignature · 12 lines
Best regards, José Quaresma -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#59934): https://lists.yoctoproject.org/g/yocto/message/59934 Mute This Topic: https://lists.yoctoproject.org/mt/98557297/1792208 Group Owner: [email protected] Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
Re: [yocto] [meta-security][PATCH 7/8] linux: overlayfs: Add kernel patch resolving a file change notification issue
Stefan Berger <[email protected]> escreveu no dia terça, 9/05/2023 à(s) 19:05:
Quoted 33 lines · Jose Quaresma
Quoted 1 line
Stefan Berger <stefanb@ linux. ibm. com> escreveu no dia terça,
9/05/2023 à(s) 17: 21: On 5/9/23 10: 53, Jose Quaresma wrote: > Hi Stefan,
Quoted 1 line
Quoted 1 line
Having this patch applied unconditionally to all kernels doesn't work
and the patch
Quoted 7 lines
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
ZjQcmQRYFpfptBannerEndStefan Berger <[email protected] <mailto:[email protected]>>
escreveu no dia terça, 9/05/2023 à(s) 17:21:
Quoted 7 lines · Jose Quaresma
> Hi Stefan,
>
> Having this patch applied unconditionally to all kernels doesn'twork and the patch fails in many downstream kernels.
Quoted 3 lines
> I suggest reverting this one if no other solutions come up.
Then let me drop this one. I just posted v2 of this series and can
repost in v3 with this patch dropped and possibly
Quoted 1 line
only have it applied in the OpenBMC project. I suppose my conclusion
from OpenBMC, which currently works with a 6.1.15
Quoted 1 line
kernel, that all other Yocto projects also now use a >= 6.1.15
kernel, was wrong?
Quoted 2 lines
Quoted 8 lines
Quoted 2 lines
yup! is also my opinion.
but after reverting this patch some other new issues comes up becausethe ima side effects changes
Quoted 1 line
so linux-firmware dont build any more.
Can you either point me to the changes or tell me how you build linux-firmware so that I can recreate the issue locally?
it's easy, just call the following:
bitbake linux-firmware
Quoted 201 lines
Stefan
Quoted 10 lines
Jose
Stefan > > Jose > > Stefan Berger <[email protected] <mailto:[email protected]> <mailto:[email protected] <mailto:
[email protected]>>> escreveu no dia sexta, 28/04/2023 à(s) 13:55:Quoted 7 lines
> > > > On 4/28/23 08:48, Mikko Rapeli wrote: > > Hi, > > > > On Fri, Apr 28, 2023 at 08:23:15AM -0400, Stefan BergerQuoted 1 line · wrote:
> >> Add a temporary patch that resolves a file change
notification issue
Quoted 1 line
> >> with overlayfs where IMA did not become aware of the file
changes
Quoted 1 line
> >> since the 'lower' inode's
i_versionhad not changed. Theissue will be
Quoted 1 line
> >> resolved in later kernels with the following patch that
builds on
Quoted 1 line
> >> newly addd feature (support for
STATX_CHANGE_COOKIE) inv6.3-rc1:
Quoted 2 lines
> >> > >>https://lore.kernel.org/linux-integrity/20230418-engste-gastwirtschaft-601fb389bba5@brauner/T/#m3bf84296fe9e6499abb6e3191693948add2ff459
<
https://lore.kernel.org/linux-integrity/20230418-engste-gastwirtschaft-601fb389bba5@brauner/T/#m3bf84296fe9e6499abb6e3191693948add2ff459>
<
https://lore.kernel.org/linux-integrity/20230418-engste-gastwirtschaft-601fb389bba5@brauner/T/#m3bf84296fe9e6499abb6e3191693948add2ff459
<
https://lore.kernel.org/linux-integrity/20230418-engste-gastwirtschaft-601fb389bba5@brauner/T/#m3bf84296fe9e6499abb6e3191693948add2ff459Quoted 3 lines
Quoted 1 line
> >
> > Would be nice to have Upstream-Status for each patch. Iguess status
Quoted 3 lines
> > would be Backport here.
>
> It's quite possible that this series herehttps://lkml.org/lkml/2022/10/21/624 <https://lkml.org/lkml/2022/10/21/624
Quoted 2 lines
> (alone? <https://lkml.org/lkml/2022/10/21/624(alone <https://lkml.org/lkml/2022/10/21/624(alone>?>) would provide the infrastructure for
STATX_CHANGE_COOKIE(introduced in 3/8)Quoted 1 line
> and have that referenced patch applied which isn't upstreamed
so far, either.
Quoted 2 lines
>
> For now this two-liner seemed simpler and resolves the issue.I understand the concern, though...
Quoted 9 lines
>
> Stefan
>
> >
> > Cheers,
> >
> > -Mikko
> >
> >> Signed-off-by: Stefan Berger <[email protected]<mailto:[email protected]> <mailto:[email protected] <mailto:
[email protected]>>>Quoted 2 lines
> >> ---
> >> ...Increment-iversion-upon-file-changes.patch | 42+++++++++++++++++++
Quoted 3 lines
> >> .../recipes-kernel/linux/linux_ima.inc | 1 + > >> 2 files changed, 43 insertions(+) > >> create mode 100644
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patchQuoted 2 lines
> >> > >> diff --git
a/meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patchb/meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patchQuoted 4 lines
> >> new file mode 100644 > >> index 0000000..d2b5c28 > >> --- /dev/null > >> +++
b/meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patchQuoted 2 lines
> >> @@ -0,0 +1,42 @@ > >> +From e9ed62e8d1d3eee7ffe862d9812c5320d3b9bd88 Mon Sep 1700:00:00 2001
Quoted 1 line
> >> +From: Stefan Berger <[email protected] <mailto:
[email protected]> <mailto:[email protected] <mailto:
[email protected]>>>Quoted 2 lines
> >> +Date: Thu, 6 Apr 2023 11:27:29 -0400
> >> +Subject: [PATCH] ovl: Increment iversion upon filechanges
Quoted 2 lines
> >> +
> >> +This is a temporary patch for kernels that do notimplement
Quoted 1 line
> >> +STATX_CHANGE_COOKIE (<= 6.2). The successor patch will
be this one:
Quoted 2 lines
> >> + > >> +https://lore.kernel.org/linux-integrity/20230418-engste-gastwirtschaft-601fb389bba5@brauner/T/#m3bf84296fe9e6499abb6e3191693948add2ff459
<
https://lore.kernel.org/linux-integrity/20230418-engste-gastwirtschaft-601fb389bba5@brauner/T/#m3bf84296fe9e6499abb6e3191693948add2ff459>
<
https://lore.kernel.org/linux-integrity/20230418-engste-gastwirtschaft-601fb389bba5@brauner/T/#m3bf84296fe9e6499abb6e3191693948add2ff459
<
https://lore.kernel.org/linux-integrity/20230418-engste-gastwirtschaft-601fb389bba5@brauner/T/#m3bf84296fe9e6499abb6e3191693948add2ff459Quoted 3 lines
Quoted 1 line
> >> +
> >> +Increment the lower inode's iversion for IMA to be ableto recognize
Quoted 3 lines
> >> +changes to the file. > >> + > >> +Signed-off-by: Stefan Berger <[email protected]<mailto:[email protected]> <mailto:[email protected] <mailto:
[email protected]>>>Quoted 9 lines
> >> +--- > >> + 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 @@Quoted 8 lines
> >> + #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(structkiocb *iocb, struct
iov_iter*iter)Quoted 4 lines
> >> + if (ret != -EIOCBQUEUED) > >> + ovl_aio_cleanup_handler(aio_req); > >> + } > >> ++ if (ret > 0)Quoted 8 lines
> >> ++ inode_maybe_inc_iversion(inode, false); > >> + out: > >> + revert_creds(old_cred); > >> + out_fdput: > >> +-- > >> +2.34.1 > >> + > >> diff --gita/meta-integrity/recipes-kernel/linux/linux_ima.inc b/meta-integrity/recipes-kernel/linux/linux_ima.inc
Quoted 4 lines
> >> index 0b6f530..9d48e5c 100644 > >> --- a/meta-integrity/recipes-kernel/linux/linux_ima.inc > >> +++ b/meta-integrity/recipes-kernel/linux/linux_ima.inc > >> @@ -2,6 +2,7 @@ FILESEXTRAPATHS:append :="${THISDIR}/linux:"
Quoted 3 lines
> >> > >> SRC_URI += " \ > >> ${@bb.utils.contains('DISTRO_FEATURES', 'ima','file://ima.scc', '', d)} \
Quoted 1 line
> >> +file://0001-ovl-Increment-iversion-upon-file-changes.patch \
Quoted 26 lines
> >> " > >> > >> do_configure() { > >> -- > >> 2.34.1 > >> > > > >> > >> > >> > > > > > > > > -- > Best regards, > > José Quaresma--
Best regards,Quoted 6 lines
José Quaresma
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#59934):https://lists.yoctoproject.org/g/yocto/message/59934
Quoted 3 lines
Mute This Topic: https://lists.yoctoproject.org/mt/98557297/1792208
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [Quoted 2 lines
-=-=-=-=-=-=-=-=-=-=-=-
Signature · 3 lines
Best regards, José Quaresma
Re: [yocto] [meta-security][PATCH 7/8] linux: overlayfs: Add kernel patch resolving a file change notification issue
Quoted 6 lines · Jose Quaresma
it's easy, just call the following:
bitbake linux-firmware
How do you initialize this environment?
If I was to do this from meta-security I get this here:
$ bitbake linux-firmware ERROR: The BBPATH variable is not set and bitbake did not find a conf/bblayers.conf file in the expected location. Maybe you accidentally invoked bitbake from the wrong directory?
Stefan
Re: [yocto] [meta-security][PATCH 7/8] linux: overlayfs: Add kernel patch resolving a file change notification issue
In reply to Jose QuaresmaQuoted 4 lines · Jose Quaresma
Hi Stefan,
Having this patch applied unconditionally to all kernels doesn't work and the patch fails in many downstream kernels. I suggest reverting this one if no other solutions come up.
Oh, I just saw the patches were applied to meta-security already. Alright, I will send a separate patch to drop this patch.
Stefan
Quoted 129 lines
Jose
Stefan Berger <[email protected] <mailto:[email protected]>> escreveu no dia sexta, 28/04/2023 à(s) 13:55:
On 4/28/23 08:48, Mikko Rapeli wrote: > Hi, > > On Fri, Apr 28, 2023 at 08:23:15AM -0400, Stefan Berger wrote: >> Add a temporary patch that resolves a file change notification issue >> with overlayfs where IMA did not become aware of the file changes >> since the 'lower' inode's i_version had not changed. The issue will be >> resolved in later kernels with the following patch that builds on >> newly addd feature (support for STATX_CHANGE_COOKIE) in v6.3-rc1: >> >> https://lore.kernel.org/linux-integrity/20230418-engste-gastwirtschaft-601fb389bba5@brauner/T/#m3bf84296fe9e6499abb6e3191693948add2ff459 <https://lore.kernel.org/linux-integrity/20230418-engste-gastwirtschaft-601fb389bba5@brauner/T/#m3bf84296fe9e6499abb6e3191693948add2ff459> > > Would be nice to have Upstream-Status for each patch. I guess status > would be Backport here. It's quite possible that this series here https://lkml.org/lkml/2022/10/21/624 (alone? <https://lkml.org/lkml/2022/10/21/624(alone?>) would provide the infrastructure for STATX_CHANGE_COOKIE (introduced in 3/8) and have that referenced patch applied which isn't upstreamed so far, either. For now this two-liner seemed simpler and resolves the issue. I understand the concern, though... Stefan > > Cheers, > > -Mikko > >> Signed-off-by: Stefan Berger <[email protected] <mailto:[email protected]>> >> --- >> ...Increment-iversion-upon-file-changes.patch | 42 +++++++++++++++++++ >> .../recipes-kernel/linux/linux_ima.inc | 1 + >> 2 files changed, 43 insertions(+) >> create mode 100644 meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch >> >> diff --git a/meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch b/meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch >> new file mode 100644 >> index 0000000..d2b5c28 >> --- /dev/null >> +++ b/meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch >> @@ -0,0 +1,42 @@ >> +From e9ed62e8d1d3eee7ffe862d9812c5320d3b9bd88 Mon Sep 17 00:00:00 2001 >> +From: Stefan Berger <[email protected] <mailto:[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 <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] <mailto:[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 >> + >> diff --git a/meta-integrity/recipes-kernel/linux/linux_ima.inc b/meta-integrity/recipes-kernel/linux/linux_ima.inc >> index 0b6f530..9d48e5c 100644 >> --- a/meta-integrity/recipes-kernel/linux/linux_ima.inc >> +++ b/meta-integrity/recipes-kernel/linux/linux_ima.inc >> @@ -2,6 +2,7 @@ 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() { >> -- >> 2.34.1 >> > >> >> >> >Signature · 12 lines
Best regards, José Quaresma -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#59928): https://lists.yoctoproject.org/g/yocto/message/59928 Mute This Topic: https://lists.yoctoproject.org/mt/98557297/1792208 Group Owner: [email protected] Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [yocto] [meta-security][PATCH 7/8] linux: overlayfs: Add kernel patch resolving a file change notification issue
And it fails in other recipes like linux-firmware.
Because bitbake also tries to apply the patch to linux-firmware because it uses the recipes-kernel/linux/linux-%.bbappend to check when the integrity is enabled.
Jose
Jose Quaresma via lists.yoctoproject.org <quaresma.jose= [email protected]> escreveu no dia terça, 9/05/2023 à(s) 15:53:
Quoted 151 lines
Hi Stefan,
Having this patch applied unconditionally to all kernels doesn't work and the patch fails in many downstream kernels.
I suggest reverting this one if no other solutions come up.Jose
Stefan Berger <[email protected]> escreveu no dia sexta, 28/04/2023 à(s) 13:55:
Quoted 99 lines · Mikko Rapeli
Quoted 10 lines
Hi,
Quoted 7 lines · Stefan Berger
Add a temporary patch that resolves a file change notification issue with overlayfs where IMA did not become aware of the file changes since the 'lower' inode's
i_versionhad not changed. The issue will be resolved in later kernels with the following patch that builds on newly addd feature (support forSTATX_CHANGE_COOKIE) in v6.3-rc1:Quoted 3 lines
Would be nice to have Upstream-Status for each patch. I guess status would be Backport here.
It's quite possible that this series here
https://lkml.org/lkml/2022/10/21/624
(alone? <https://lkml.org/lkml/2022/10/21/624(alone?>) would provide the infrastructure forSTATX_CHANGE_COOKIE(introduced in 3/8) and have that referenced patch applied which isn't upstreamed so far, either.For now this two-liner seemed simpler and resolves the issue. I understand the concern, though...
Stefan
Quoted 8 lines
Cheers,
-Mikko
Quoted 3 lines
Signed-off-by Stefan Berger <[email protected]>--- ...Increment-iversion-upon-file-changes.patch | 42+++++++++++++++++++
Quoted 3 lines
Quoted 3 lines
.../recipes-kernel/linux/linux_ima.inc | 1 + 2 files changed, 43 insertions(+)create mode 100644
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patchQuoted 2 lines
Quoted 2 lines
diff --git
a/meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patchb/meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patchQuoted 4 lines
Quoted 4 lines
new file mode 100644
index 0000000..d2b5c28
---/dev/null
+++
b/meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patchQuoted 10 lines
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch line 9
Quoted 10 lines
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch new file +9
-0@@ -0,0 +1,42 @@ +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: + +Quoted 14 lines
Quoted 14 lines
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch new file +14
-0+ +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 @@Quoted 8 lines
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch
Quoted 8 lines
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch new file +8
-0+ #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)Quoted 4 lines
Quoted 4 lines
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch new file +4
-0+ if (ret != -EIOCBQUEUED) + ovl_aio_cleanup_handler(aio_req); + } ++ if (ret > 0)Quoted 8 lines
Review
Quoted 8 lines
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch new file +7
-0++ inode_maybe_inc_iversion(inode, false); + out: + revert_creds(old_cred); + out_fdput: +-- +2.34.1 +(quoted diff) +0
-0b/meta-integrity/recipes-kernel/linux/linux_ima.inc
Quoted 24 lines
Quoted 7 lines
meta-integrity/recipes-kernel/linux/linux_ima.inc FILESEXTRAPATHS:append := "${THISDIR}/linux:" · line 4
Quoted 7 lines
index 0b6f530..9d48e5c 100644
meta-integrity/recipes-kernel/linux/linux_ima.inc +0
-0@@ -2,6 +2,7 @@ FILESEXTRAPATHS:append := "${THISDIR}/linux:" SRC_URI += " \ ${@bb.utils.contains('DISTRO_FEATURES', 'ima', 'file://ima.scc','', d)} \
Quoted 12 lines
Quoted 11 lines
meta-integrity/recipes-kernel/linux/linux_ima.inc +1
-1+ file://0001-ovl-Increment-iversion-upon-file-changes.patch \ " do_configure() { --2.34.1
--
Best regards,José Quaresma
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#59928):
https://lists.yoctoproject.org/g/yocto/message/59928
Mute This Topic: https://lists.yoctoproject.org/mt/98557297/5052612
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Signature · 3 lines
Best regards, José Quaresma
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [yocto] [meta-security][PATCH 7/8] linux: overlayfs: Add kernel patch resolving a file change notification issue
Jose Quaresma via lists.yoctoproject.org <quaresma.jose= [email protected]> escreveu no dia terça, 9/05/2023 à(s) 16:06:
Quoted 5 lines
And it fails in other recipes like linux-firmware.
Because bitbake also tries to apply the patch to linux-firmware because it uses the recipes-kernel/linux/linux-%.bbappend to check when the integrity is enabled.
I believe that the full patchset needs to be reverted because it also breaks linux-firmware even reverting this patch.
Jose
Quoted 168 lines
Jose
Jose Quaresma via lists.yoctoproject.org <quaresma.jose= [email protected]> escreveu no dia terça, 9/05/2023 à(s) 15:53:
Quoted 136 lines
Hi Stefan,
Having this patch applied unconditionally to all kernels doesn't work and the patch fails in many downstream kernels.
I suggest reverting this one if no other solutions come up.Jose
Stefan Berger <[email protected]> escreveu no dia sexta, 28/04/2023 à(s) 13:55:
Quoted 100 lines · Mikko Rapeli
Quoted 10 lines
Hi,
Quoted 7 lines · Stefan Berger
Add a temporary patch that resolves a file change notification issue with overlayfs where IMA did not become aware of the file changes since the 'lower' inode's
i_versionhad not changed. The issue will be resolved in later kernels with the following patch that builds on newly addd feature (support forSTATX_CHANGE_COOKIE) in v6.3-rc1:Quoted 3 lines
Would be nice to have Upstream-Status for each patch. I guess status would be Backport here.
It's quite possible that this series here
https://lkml.org/lkml/2022/10/21/624
(alone? <https://lkml.org/lkml/2022/10/21/624(alone?>) would provide the infrastructure forSTATX_CHANGE_COOKIE(introduced in 3/8) and have that referenced patch applied which isn't upstreamed so far, either.For now this two-liner seemed simpler and resolves the issue. I understand the concern, though...
Stefan
Quoted 8 lines
Cheers,
-Mikko
Quoted 3 lines
Signed-off-by Stefan Berger <[email protected]>--- ...Increment-iversion-upon-file-changes.patch | 42+++++++++++++++++++
Quoted 3 lines
Quoted 3 lines
.../recipes-kernel/linux/linux_ima.inc | 1 + 2 files changed, 43 insertions(+)create mode 100644
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patchQuoted 2 lines
Quoted 2 lines
diff --git
a/meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patchb/meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patchQuoted 4 lines
Quoted 4 lines
new file mode 100644
index 0000000..d2b5c28
---/dev/null
+++
b/meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patchQuoted 2 lines
Review line 1
Quoted 2 lines
(quoted diff) +1
-0@@ -0,0 +1,42 @@ +From e9ed62e8d1d3eee7ffe862d9812c5320d3b9bd88 Mon Sep 17 00:00:002001
Quoted 8 lines
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch line 10
Quoted 8 lines
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch new file +8
-0+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: + +Quoted 14 lines
Quoted 14 lines
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch new file +14
-0+ +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 @@Quoted 8 lines
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch
Quoted 8 lines
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch new file +8
-0+ #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)Quoted 4 lines
Quoted 4 lines
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch new file +4
-0+ if (ret != -EIOCBQUEUED) + ovl_aio_cleanup_handler(aio_req); + } ++ if (ret > 0)Quoted 8 lines
Review
Quoted 8 lines
meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch new file +7
-0++ inode_maybe_inc_iversion(inode, false); + out: + revert_creds(old_cred); + out_fdput: +-- +2.34.1 +(quoted diff) +0
-0b/meta-integrity/recipes-kernel/linux/linux_ima.inc
Quoted 24 lines
Quoted 7 lines
meta-integrity/recipes-kernel/linux/linux_ima.inc FILESEXTRAPATHS:append := "${THISDIR}/linux:" · line 4
Quoted 7 lines
index 0b6f530..9d48e5c 100644
meta-integrity/recipes-kernel/linux/linux_ima.inc +0
-0@@ -2,6 +2,7 @@ FILESEXTRAPATHS:append := "${THISDIR}/linux:" SRC_URI += " \ ${@bb.utils.contains('DISTRO_FEATURES', 'ima','file://ima.scc', '', d)} \
Quoted 12 lines
Quoted 11 lines
meta-integrity/recipes-kernel/linux/linux_ima.inc +1
-1+ file://0001-ovl-Increment-iversion-upon-file-changes.patch \ " do_configure() { --2.34.1
Quoted 8 lines
--
Best regards,José Quaresma
--
Best regards,José Quaresma
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#59929):
https://lists.yoctoproject.org/g/yocto/message/59929
Mute This Topic: https://lists.yoctoproject.org/mt/98557297/5052612
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Signature · 3 lines
Best regards, José Quaresma
PATCH 8/8 ima-evm-utils: Update ima-evm-utils to v1.5 and add a patch
In reply to Stefan Berger---
...ation-using-ioctl-when-evm_portable-.patch | 35 +++++++++++++++++++
...-evm-utils_1.4.bb => ima-evm-utils_1.5.bb} | 9 +++--
2 files changed, 42 insertions(+), 2 deletions(-)
create mode 100644 meta-integrity/recipes-security/ima-evm-utils/ima-evm-utils/0001-Do-not-get-generation-using-ioctl-when-evm_portable-.patch
rename meta-integrity/recipes-security/ima-evm-utils/{ima-evm-utils_1.4.bb => ima-evm-utils_1.5.bb} (71%)meta-integrity/recipes-security/ima-evm-utils/ima-evm-utils/0001-Do-not-get-generation-using-ioctl-when-evm_portable-.patch new file +35 -0
@@ -0,0 +1,35 @@ +From 00ace817c5134d9844db387cadb9517ebad43808 Mon Sep 17 00:00:00 2001 +From: Stefan Berger <[email protected]> +Date: Tue, 18 Apr 2023 11:43:55 -0400 +Subject: [PATCH] Do not get generation using ioctl when evm_portable is true + +If a signatures is detected as being portable do not attempt to read the +generation with the ioctl since in some cases this may not be supported +by the filesystem and is also not needed for computing a portable +signature. + +This avoids the current work-around of passing --generation 0 when the +ioctl is not supported by the filesystem. + +Signed-off-by: Stefan Berger <[email protected]> +--- + src/evmctl.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/evmctl.c b/src/evmctl.c +index 6d2bb67..c35a28c 100644 +--- a/src/evmctl.c ++++ b/src/evmctl.c +@@ -376,7 +376,7 @@ static int calc_evm_hash(const char *file, unsigned char *hash) + if (mode_str) + st.st_mode = strtoul(mode_str, NULL, 10); + +- if (!evm_immutable) { ++ if (!evm_immutable && !evm_portable) { + if (S_ISREG(st.st_mode) && !generation_str) { + int fd = open(file, 0); + +--- +2.39.2 + +
meta-integrity/recipes-security/ima-evm-utils/ima-evm-utils_1.5.bb renamed from meta-integrity/recipes-security/ima-evm-utils/ima-evm-utils_1.4.bb +7 -2
@@ -6,8 +6,13 @@ DEPENDS += "openssl attr keyutils" DEPENDS:class-native += "openssl-native keyutils-native" -SRC_URI = "https://sourceforge.net/projects/linux-ima/files/${BPN}/${BP}.tar.gz" -SRC_URI[sha256sum] = "fcf85b31d6292051b3679e5f17ffa7f89b6898957aad0f59aa4e9878884b27d1" +FILESEXTRAPATHS:append := "${THISDIR}/${PN}:" + +SRC_URI = " \ + https://github.com/mimizohar/ima-evm-utils/releases/download/v${PV}/${BP}.tar.gz \ + file://0001-Do-not-get-generation-using-ioctl-when-evm_portable-.patch \ +" +SRC_URI[sha256sum] = "45f1caa3ad59ec59a1d6a74ea5df38c413488cd952ab62d98cf893c15e6f246d" inherit pkgconfig autotools features_check
Signature · 1 line
2.34.1
Stefan,
Quoted 6 lines · Stefan Berger
This series of patches fixes the current support for IMA and EVM by removing outdated patches for example and adding kernel config options. I have tried out these patches with OpenBMC where the appraisal policy now enforces signed executables and libraries.
Stefan
Thanks for the patches. Its nice to have a Content expert contribute.
There is a test suite I am using to double check things and its not passing. I think it needs to be adapted to some of these changes.
see: meta-integrity/lib/oeqa/runtime/cases/ima.py
This is adding a delay on merging until I get the test sorted out on my end.
I do have a question regarding the Kernel config changes. Do we really need "CONFIG_SQUASHFS_XATTR=y" ?
BR,
Armin
Quoted 47 lines
Stefan Berger (8):
ima: Document and replace keys and adapt scripts for EC keys
ima: Fix theima_policy_appraise_allto appraise executables &
libraries
ima: Fix the IMA kernel feature
ima: RenameIMA_EVM_POLICY_SYSTEMDtoIMA_EVM_POLICY
ima: Sign all executables and the ima-policy in the root filesystem
integrity: Update the README for IMA support
linux: overlayfs: Add kernel patch resolving a file change
notification issue
ima-evm-utils: Update ima-evm-utils to v1.5 and add a patchmeta-integrity/README.md | 22 +-- meta-integrity/classes/ima-evm-rootfs.bbclass | 34 ++++- meta-integrity/data/debug-keys/README.md | 17 +++ .../data/debug-keys/ima-local-ca.pem | 15 ++ .../data/debug-keys/ima-local-ca.priv | 7 + .../data/debug-keys/privkey_ima.pem | 17 +-- meta-integrity/data/debug-keys/x509_ima.der | Bin 707 -> 620 bytes .../0001-ima-fix-ima_inode_post_setattr.patch | 51 ------- ...Increment-iversion-upon-file-changes.patch | 42 ++++++ ...for-creating-files-using-the-mknodat.patch | 138 ------------------ ...-file-hash-setting-by-user-to-fix-an.patch | 60 -------- .../recipes-kernel/linux/linux/ima.cfg | 46 ++++++ .../recipes-kernel/linux/linux/ima.scc | 4 + .../recipes-kernel/linux/linux_ima.inc | 11 +- ...ation-using-ioctl-when-evm_portable-.patch | 35 +++++ ...-evm-utils_1.4.bb => ima-evm-utils_1.5.bb} | 9 +- .../files/ima_policy_appraise_all | 9 +- meta-integrity/scripts/ima-gen-CA-signed.sh | 9 +- meta-integrity/scripts/ima-gen-local-ca.sh | 6 +- meta-integrity/scripts/ima-gen-self-signed.sh | 41 ------ 20 files changed, 240 insertions(+), 333 deletions(-)create mode 100644
meta-integrity/data/debug-keys/README.md
create mode 100644 meta-integrity/data/debug-keys/ima-local-ca.pem
create mode 100644 meta-integrity/data/debug-keys/ima-local-ca.priv
delete mode 100644meta-integrity/recipes-kernel/linux/linux/0001-ima-fix-ima_inode_post_setattr.patch
create mode 100644meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patchdelete mode 100644meta-integrity/recipes-kernel/linux/linux/0002-ima-add-support-for-creating-files-using-the-mknodat.patchdelete mode 100644meta-integrity/recipes-kernel/linux/linux/Revert-ima-limit-file-hash-setting-by-user-to-fix-an.patchcreate mode 100644 meta-integrity/recipes-kernel/linux/linux/ima.cfg
create mode 100644 meta-integrity/recipes-kernel/linux/linux/ima.scc
create mode 100644meta-integrity/recipes-security/ima-evm-utils/ima-evm-utils/0001-Do-not-get-generation-using-ioctl-when-evm_portable-.patchrename meta-integrity/recipes-security/ima-evm-utils/{ima-evm-utils_1.4.bb => ima-evm-utils_1.5.bb} (71%)
delete mode 100755meta-integrity/scripts/ima-gen-self-signed.sh
Quoted 9 lines · Armin Kuster
Stefan,
Quoted 5 lines · Stefan Berger
This series of patches fixes the current support for IMA and EVM by removing outdated patches for example and adding kernel config options. I have tried out these patches with OpenBMC where the appraisal policy now enforces signed executables and libraries.
Quoted 7 lines
Quoted 1 line
Stefan
Thanks for the patches. Its nice to have a Content expert contribute.
There is a test suite I am using to double check things and its not passing. I think it needs to be adapted to some of these changes.
see:
meta-integrity/lib/oeqa/runtime/cases/ima.py
How does one run the test suite? I have so far only used the changes with a build of OpenBMC. I had seen the tests, though, and saw they assumed IMA was going to start before systemd. In the OpenBMC log I see this here:
[ 0.984195] ima: No TPM chip found, activating TPM-bypass! [ 0.985167] ima: Allocated hash algorithm: sha256 [ 0.991810] ima: No architecture policies found
These are easy...
This one is due to me adding IMA policy load support into an init script:
Activated EVM: 2 [ activated with 0x80000002 ]
[ 2.248222] ima: policy update completed
My patches for OpenBMC are here:
https://gerrit.openbmc.org/c/openbmc/openbmc/+/62933
This one has the init script changes: https://gerrit.openbmc.org/c/openbmc/openbmc/+/62929/1
Quoted 5 lines
This is adding a delay on merging until I get the test sorted out on my end.
I do have a question regarding the Kernel config changes. Do we really need "
CONFIG_SQUASHFS_XATTR=y" ?
I added this because of OpenBMC using squashfs and we need the xattr support for security.ima and .evm.
Regards,
Stefan
Quoted 63 lines
BR,
ArminQuoted 34 lines
Stefan Berger (8):
ima: Document and replace keys and adapt scripts for EC keys
ima: Fix theima_policy_appraise_allto appraise executables & libraries
ima: Fix the IMA kernel feature
ima: RenameIMA_EVM_POLICY_SYSTEMDtoIMA_EVM_POLICY
ima: Sign all executables and the ima-policy in the root filesystem
integrity: Update the README for IMA support
linux: overlayfs: Add kernel patch resolving a file change notification issue
ima-evm-utils: Update ima-evm-utils to v1.5 and add a patchmeta-integrity/README.md | 22 +-- meta-integrity/classes/ima-evm-rootfs.bbclass | 34 ++++- meta-integrity/data/debug-keys/README.md | 17 +++ .../data/debug-keys/ima-local-ca.pem | 15 ++ .../data/debug-keys/ima-local-ca.priv | 7 + .../data/debug-keys/privkey_ima.pem | 17 +-- meta-integrity/data/debug-keys/x509_ima.der | Bin 707 -> 620 bytes
.../0001-ima-fix-ima_inode_post_setattr.patch | 51 ------- ...Increment-iversion-upon-file-changes.patch | 42 ++++++ ...for-creating-files-using-the-mknodat.patch | 138 ------------------ ...-file-hash-setting-by-user-to-fix-an.patch | 60 -------- .../recipes-kernel/linux/linux/ima.cfg | 46 ++++++ .../recipes-kernel/linux/linux/ima.scc | 4 + .../recipes-kernel/linux/linux_ima.inc | 11 +-...ation-using-ioctl-when-evm_portable-.patch | 35 +++++ ...-evm-utils_1.4.bb => ima-evm-utils_1.5.bb} | 9 +- .../files/ima_policy_appraise_all | 9 +- meta-integrity/scripts/ima-gen-CA-signed.sh | 9 +- meta-integrity/scripts/ima-gen-local-ca.sh | 6 +-
meta-integrity/scripts/ima-gen-self-signed.sh| 41 ------20 files changed, 240 insertions(+), 333 deletions(-)Quoted 13 lines
create mode 100644
meta-integrity/data/debug-keys/README.md
create mode 100644 meta-integrity/data/debug-keys/ima-local-ca.pem
create mode 100644 meta-integrity/data/debug-keys/ima-local-ca.priv
delete mode 100644meta-integrity/recipes-kernel/linux/linux/0001-ima-fix-ima_inode_post_setattr.patch
create mode 100644meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patchdelete mode 100644meta-integrity/recipes-kernel/linux/linux/0002-ima-add-support-for-creating-files-using-the-mknodat.patchdelete mode 100644meta-integrity/recipes-kernel/linux/linux/Revert-ima-limit-file-hash-setting-by-user-to-fix-an.patchcreate mode 100644 meta-integrity/recipes-kernel/linux/linux/ima.cfg
create mode 100644 meta-integrity/recipes-kernel/linux/linux/ima.scc
create mode 100644meta-integrity/recipes-security/ima-evm-utils/ima-evm-utils/0001-Do-not-get-generation-using-ioctl-when-evm_portable-.patchrename meta-integrity/recipes-security/ima-evm-utils/{ima-evm-utils_1.4.bb => ima-evm-utils_1.5.bb} (71%)
delete mode 100755meta-integrity/scripts/ima-gen-self-signed.sh-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#59823): https://lists.yoctoproject.org/g/yocto/message/59823
Mute This Topic: https://lists.yoctoproject.org/mt/98557294/1792208
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Quoted 14 lines · Stefan Berger
Quoted 11 lines · Armin Kuster
Stefan,
Quoted 6 lines · Stefan Berger
This series of patches fixes the current support for IMA and EVM by removing outdated patches for example and adding kernel config options. I have tried out these patches with OpenBMC where the appraisal policy now enforces signed executables and libraries.
Stefan
Quoted 7 lines
Quoted 5 lines
Thanks for the patches. Its nice to have a Content expert contribute.
There is a test suite I am using to double check things and its not passing. I think it needs to be adapted to some of these changes.
see:
meta-integrity/lib/oeqa/runtime/cases/ima.pyHow does one run the test suite?
There is an image unique to most the meta-security sub layers used to building & testing. In this IMA case its "integrity-image-minimal"
To run the test suite, add to your local.conf:
#####################
DISTRO_FEATURES:append = " systemd integrity ima "
TEST_SUITES = "ssh ping ima"
IMAGE_CLASSES += "testimage"
#####################
Then build and test:
bitbake integrity-image-minimal; bitbake integrity-image-minimal -c testimage
It will print the test results when completed, looking like this.
RESULTS:
RESULTS - ping.PingTest.test_ping: PASSED (0.05s)
RESULTS - ssh.SSHTest.test_ssh: PASSED (2.85s)
RESULTS - ima.IMACheck.test_ima_before_systemd: PASSED (2.56s)
RESULTS - ima.IMACheck.test_ima_enabled: PASSED (1.38s)
RESULTS - ima.IMACheck.test_ima_hash: PASSED (5.65s)
RESULTS - ima.IMACheck.test_ima_overwrite: PASSED (267.05s)
RESULTS - ima.IMACheck.test_ima_signature: PASSED (145.66s)
SUMMARY:
integrity-image-minimal () - Ran 7 tests in 427.742s
integrity-image-minimal - OK - All required tests passed (successes=7, skipped=0, failures=0, errors=0)
I just posted the changes needed to get the tests passing again.
Quoted 12 lines
I have so far only used the changes with a build of OpenBMC.
I had seen the tests, though, and saw they assumed IMA was going to start before systemd. In the OpenBMC log I see this here:[ 0.984195] ima: No TPM chip found, activating TPM-bypass! [ 0.985167] ima: Allocated hash algorithm: sha256 [ 0.991810] ima: No architecture policies found
These are easy...
This one is due to me adding IMA policy load support into an init script:
Quoted 8 lines
Activated EVM: 2 [ activated with
0x80000002]
[ 2.248222] ima: policy update completedMy patches for OpenBMC are here:
https://gerrit.openbmc.org/c/openbmc/openbmc/+/62933
This one has the init script changes: https://gerrit.openbmc.org/c/openbmc/openbmc/+/62929/1
Thanks for the links, I will take a look.
Quoted 8 lines
Quoted 6 lines
This is adding a delay on merging until I get the test sorted out on my end.
I do have a question regarding the Kernel config changes. Do we really need "
CONFIG_SQUASHFS_XATTR=y" ?I added this because of OpenBMC using squashfs and we need the xattr support for security.ima and .evm.
ok,
BR,
Armin
Quoted 70 lines
Regards,
StefanQuoted 64 lines
BR,
ArminQuoted 35 lines
Stefan Berger (8):
ima: Document and replace keys and adapt scripts for EC keys
ima: Fix theima_policy_appraise_allto appraise executables & libraries
ima: Fix the IMA kernel feature
ima: RenameIMA_EVM_POLICY_SYSTEMDtoIMA_EVM_POLICY
ima: Sign all executables and the ima-policy in the root filesystem
integrity: Update the README for IMA support
linux: overlayfs: Add kernel patch resolving a file change notification issue
ima-evm-utils: Update ima-evm-utils to v1.5 and add a patchmeta-integrity/README.md | 22 +-- meta-integrity/classes/ima-evm-rootfs.bbclass | 34 ++++- meta-integrity/data/debug-keys/README.md | 17 +++ .../data/debug-keys/ima-local-ca.pem | 15 ++ .../data/debug-keys/ima-local-ca.priv | 7 + .../data/debug-keys/privkey_ima.pem | 17 +-- meta-integrity/data/debug-keys/x509_ima.der | Bin 707 -> 620 bytes
.../0001-ima-fix-ima_inode_post_setattr.patch | 51 ------- ...Increment-iversion-upon-file-changes.patch | 42 ++++++ ...for-creating-files-using-the-mknodat.patch | 138 ------------------ ...-file-hash-setting-by-user-to-fix-an.patch | 60 -------- .../recipes-kernel/linux/linux/ima.cfg | 46 ++++++ .../recipes-kernel/linux/linux/ima.scc | 4 + .../recipes-kernel/linux/linux_ima.inc | 11 +-...ation-using-ioctl-when-evm_portable-.patch | 35 +++++ ...-evm-utils_1.4.bb => ima-evm-utils_1.5.bb} | 9 +- .../files/ima_policy_appraise_all | 9 +- meta-integrity/scripts/ima-gen-CA-signed.sh | 9 +- meta-integrity/scripts/ima-gen-local-ca.sh | 6 +-
meta-integrity/scripts/ima-gen-self-signed.sh| 41 ------20 files changed, 240 insertions(+), 333 deletions(-)Quoted 13 lines
create mode 100644
meta-integrity/data/debug-keys/README.md
create mode 100644 meta-integrity/data/debug-keys/ima-local-ca.pem
create mode 100644 meta-integrity/data/debug-keys/ima-local-ca.priv
delete mode 100644meta-integrity/recipes-kernel/linux/linux/0001-ima-fix-ima_inode_post_setattr.patch
create mode 100644meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patchdelete mode 100644meta-integrity/recipes-kernel/linux/linux/0002-ima-add-support-for-creating-files-using-the-mknodat.patchdelete mode 100644meta-integrity/recipes-kernel/linux/linux/Revert-ima-limit-file-hash-setting-by-user-to-fix-an.patchcreate mode 100644 meta-integrity/recipes-kernel/linux/linux/ima.cfg
create mode 100644 meta-integrity/recipes-kernel/linux/linux/ima.scc
create mode 100644meta-integrity/recipes-security/ima-evm-utils/ima-evm-utils/0001-Do-not-get-generation-using-ioctl-when-evm_portable-.patchrename meta-integrity/recipes-security/ima-evm-utils/{ima-evm-utils_1.4.bb => ima-evm-utils_1.5.bb} (71%)
delete mode 100755meta-integrity/scripts/ima-gen-self-signed.sh-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#59823): https://lists.yoctoproject.org/g/yocto/message/59823
Mute This Topic: https://lists.yoctoproject.org/mt/98557294/1792208
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Quoted 4 lines · On 4/30/23 10:16, akuster808 wrote:
This is adding a delay on merging until I get the test sorted out on my end.
I do have a question regarding the Kernel config changes. Do we really need "
CONFIG_SQUASHFS_XATTR=y" ?
I will remove this and make this an OpenBMC-specific option.
Stefan
Quoted 53 lines
BR,
ArminQuoted 47 lines
Stefan Berger (8):
ima: Document and replace keys and adapt scripts for EC keys
ima: Fix theima_policy_appraise_allto appraise executables & libraries
ima: Fix the IMA kernel feature
ima: RenameIMA_EVM_POLICY_SYSTEMDtoIMA_EVM_POLICY
ima: Sign all executables and the ima-policy in the root filesystem
integrity: Update the README for IMA support
linux: overlayfs: Add kernel patch resolving a file change notification issue
ima-evm-utils: Update ima-evm-utils to v1.5 and add a patchmeta-integrity/README.md | 22 +-- meta-integrity/classes/ima-evm-rootfs.bbclass | 34 ++++- meta-integrity/data/debug-keys/README.md | 17 +++ .../data/debug-keys/ima-local-ca.pem | 15 ++ .../data/debug-keys/ima-local-ca.priv | 7 + .../data/debug-keys/privkey_ima.pem | 17 +-- meta-integrity/data/debug-keys/x509_ima.der | Bin 707 -> 620 bytes
.../0001-ima-fix-ima_inode_post_setattr.patch | 51 ------- ...Increment-iversion-upon-file-changes.patch | 42 ++++++ ...for-creating-files-using-the-mknodat.patch | 138 ------------------ ...-file-hash-setting-by-user-to-fix-an.patch | 60 -------- .../recipes-kernel/linux/linux/ima.cfg | 46 ++++++ .../recipes-kernel/linux/linux/ima.scc | 4 + .../recipes-kernel/linux/linux_ima.inc | 11 +-...ation-using-ioctl-when-evm_portable-.patch | 35 +++++ ...-evm-utils_1.4.bb => ima-evm-utils_1.5.bb} | 9 +- .../files/ima_policy_appraise_all | 9 +- meta-integrity/scripts/ima-gen-CA-signed.sh | 9 +- meta-integrity/scripts/ima-gen-local-ca.sh | 6 +-
meta-integrity/scripts/ima-gen-self-signed.sh| 41 ------20 files changed, 240 insertions(+), 333 deletions(-)create mode 100644
meta-integrity/data/debug-keys/README.md
create mode 100644 meta-integrity/data/debug-keys/ima-local-ca.pem
create mode 100644 meta-integrity/data/debug-keys/ima-local-ca.priv
delete mode 100644meta-integrity/recipes-kernel/linux/linux/0001-ima-fix-ima_inode_post_setattr.patch
create mode 100644meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patchdelete mode 100644meta-integrity/recipes-kernel/linux/linux/0002-ima-add-support-for-creating-files-using-the-mknodat.patchdelete mode 100644meta-integrity/recipes-kernel/linux/linux/Revert-ima-limit-file-hash-setting-by-user-to-fix-an.patchcreate mode 100644 meta-integrity/recipes-kernel/linux/linux/ima.cfg
create mode 100644 meta-integrity/recipes-kernel/linux/linux/ima.scc
create mode 100644meta-integrity/recipes-security/ima-evm-utils/ima-evm-utils/0001-Do-not-get-generation-using-ioctl-when-evm_portable-.patchrename meta-integrity/recipes-security/ima-evm-utils/{ima-evm-utils_1.4.bb => ima-evm-utils_1.5.bb} (71%)
delete mode 100755meta-integrity/scripts/ima-gen-self-signed.sh