From: Mimi Zohar <zohar@linux.ibm.com>
To: linux-integrity@vger.kernel.org
Cc: Mimi Zohar <zohar@linux.ibm.com>,
Miklos Szeredi <miklos@szeredi.hu>,
Amir Goldstein <amir73il@gmail.com>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-unionfs@vger.kernel.org
Subject: [RFC PATCH] ima: differentiate overlay, pivot_root, and other pathnames
Date: Mon, 8 Nov 2021 12:01:00 -0500 [thread overview]
Message-ID: <20211108170100.148066-1-zohar@linux.ibm.com> (raw)
Relative file pathnames are included in the IMA measurement list making
it difficult to differentiate files. Permit replacing the relative
pathname with the (raw) full pathname in the measurement list.
Define a new module param named "ima.rawpath".
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
---
comment: this change does not address the simple "unshare -m" case
without pivot_root.
.../admin-guide/kernel-parameters.txt | 7 +++++++
security/integrity/ima/ima_api.c | 18 +++++++++++++++++-
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 91ba391f9b32..d49a5edcd3c3 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -1890,6 +1890,13 @@
different crypto accelerators. This option can be used
to achieve best performance for particular HW.
+ ima.rawpath= [IMA]
+ Format: <bool>
+ Default: 0
+ This parameter controls whether the IMA measurement
+ list contains the relative or raw full file pathnames
+ in the IMA measurement list.
+
init= [KNL]
Format: <full_path>
Run specified binary instead of /sbin/init as init
diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
index a64fb0130b01..42c6ff7056e6 100644
--- a/security/integrity/ima/ima_api.c
+++ b/security/integrity/ima/ima_api.c
@@ -9,14 +9,19 @@
* appraise_measurement, store_measurement and store_template.
*/
#include <linux/slab.h>
+#include <linux/moduleparam.h>
#include <linux/file.h>
#include <linux/fs.h>
+#include <linux/fs_struct.h>
#include <linux/xattr.h>
#include <linux/evm.h>
#include <linux/iversion.h>
#include "ima.h"
+static bool rawpath_enabled;
+module_param_named(rawpath, rawpath_enabled, bool, 0);
+
/*
* ima_free_template_entry - free an existing template entry
*/
@@ -390,11 +395,22 @@ void ima_audit_measurement(struct integrity_iint_cache *iint,
*/
const char *ima_d_path(const struct path *path, char **pathbuf, char *namebuf)
{
+ struct dentry *dentry = NULL;
char *pathname = NULL;
*pathbuf = __getname();
if (*pathbuf) {
- pathname = d_absolute_path(path, *pathbuf, PATH_MAX);
+ if (!rawpath_enabled) {
+ pathname = d_absolute_path(path, *pathbuf, PATH_MAX);
+ } else {
+ /* Use union/overlay full pathname */
+ if (unlikely(path->dentry->d_flags & DCACHE_OP_REAL))
+ dentry = d_real(path->dentry, NULL);
+ else
+ dentry = path->dentry;
+ pathname = dentry_path_raw(dentry, *pathbuf, PATH_MAX);
+ }
+
if (IS_ERR(pathname)) {
__putname(*pathbuf);
*pathbuf = NULL;
--
2.27.0
next reply other threads:[~2021-11-08 17:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-08 17:01 Mimi Zohar [this message]
[not found] <CAJQqANe-SFvPEEQcQrGUsn9n1aFybCOQaofvnmS+qZGvnNh7nQ@mail.gmail.com>
2021-11-10 17:39 ` [RFC PATCH] ima: differentiate overlay, pivot_root, and other pathnames Mimi Zohar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211108170100.148066-1-zohar@linux.ibm.com \
--to=zohar@linux.ibm.com \
--cc=amir73il@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).