summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Berger <stefanb@linux.ibm.com>2023-04-28 08:23:15 -0400
committerArmin Kuster <akuster808@gmail.com>2023-05-06 07:54:09 -0400
commit319522e00dfd23c78cbe28ab26b87e08a8f46993 (patch)
tree7e533662f63090672f31216be94394d78c5d045c
parentb9abf0e09bfea8f08cc7f2d68998f014abba5b3b (diff)
downloadmeta-security-319522e00dfd23c78cbe28ab26b87e08a8f46993.tar.gz
linux: overlayfs: Add kernel patch resolving a file change notification issue
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 Signed-off-by: Stefan Berger <stefanb@linux.ibm.com> Signed-off-by: Armin Kuster <akuster808@gmail.com>
-rw-r--r--meta-integrity/recipes-kernel/linux/linux/0001-ovl-Increment-iversion-upon-file-changes.patch42
-rw-r--r--meta-integrity/recipes-kernel/linux/linux_ima.inc1
2 files changed, 43 insertions, 0 deletions
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 @@
1From e9ed62e8d1d3eee7ffe862d9812c5320d3b9bd88 Mon Sep 17 00:00:00 2001
2From: Stefan Berger <stefanb@linux.ibm.com>
3Date: Thu, 6 Apr 2023 11:27:29 -0400
4Subject: [PATCH] ovl: Increment iversion upon file changes
5
6This is a temporary patch for kernels that do not implement
7STATX_CHANGE_COOKIE (<= 6.2). The successor patch will be this one:
8
9https://lore.kernel.org/linux-integrity/20230418-engste-gastwirtschaft-601fb389bba5@brauner/T/#m3bf84296fe9e6499abb6e3191693948add2ff459
10
11Increment the lower inode's iversion for IMA to be able to recognize
12changes to the file.
13
14Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
15---
16 fs/overlayfs/file.c | 3 +++
17 1 file changed, 3 insertions(+)
18
19diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
20index 6011f955436b..1dfe5e7bfe1c 100644
21--- a/fs/overlayfs/file.c
22+++ b/fs/overlayfs/file.c
23@@ -13,6 +13,7 @@
24 #include <linux/security.h>
25 #include <linux/mm.h>
26 #include <linux/fs.h>
27+#include <linux/iversion.h>
28 #include "overlayfs.h"
29
30 struct ovl_aio_req {
31@@ -408,6 +409,8 @@ static ssize_t ovl_write_iter(struct kiocb *iocb, struct iov_iter *iter)
32 if (ret != -EIOCBQUEUED)
33 ovl_aio_cleanup_handler(aio_req);
34 }
35+ if (ret > 0)
36+ inode_maybe_inc_iversion(inode, false);
37 out:
38 revert_creds(old_cred);
39 out_fdput:
40--
412.34.1
42
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:"
2 2
3SRC_URI += " \ 3SRC_URI += " \
4 ${@bb.utils.contains('DISTRO_FEATURES', 'ima', 'file://ima.scc', '', d)} \ 4 ${@bb.utils.contains('DISTRO_FEATURES', 'ima', 'file://ima.scc', '', d)} \
5 file://0001-ovl-Increment-iversion-upon-file-changes.patch \
5" 6"
6 7
7do_configure() { 8do_configure() {