From: Mimi Zohar <zohar@linux.ibm.com>
To: Roberto Sassu <roberto.sassu@huaweicloud.com>,
viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz,
dmitry.kasatkin@gmail.com, eric.snowberg@oracle.com,
paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-integrity@vger.kernel.org,
linux-security-module@vger.kernel.org,
Roberto Sassu <roberto.sassu@huawei.com>,
stable@vger.kernel.org
Subject: Re: [PATCH v2 6/7] ima: Discard files opened with O_PATH
Date: Thu, 16 Jan 2025 06:52:09 -0500 [thread overview]
Message-ID: <906089e5f4e24182dc776488959dc595c92a616c.camel@linux.ibm.com> (raw)
In-Reply-To: <20241128100621.461743-7-roberto.sassu@huaweicloud.com>
On Thu, 2024-11-28 at 11:06 +0100, Roberto Sassu wrote:
> From: Roberto Sassu <roberto.sassu@huawei.com>
>
> According to man open.2, files opened with O_PATH are not really opened. The
> obtained file descriptor is used to indicate a location in the filesystem
> tree and to perform operations that act purely at the file descriptor
> level.
>
> Thus, ignore open() syscalls with O_PATH, since IMA cares about file data.
>
> Cc: stable@vger.kernel.org # v2.6.39.x
> Fixes: 1abf0c718f15a ("New kind of open files - "location only".")
> Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
Thanks, Roberto.
Note: Ignoring open() with O_PATH impacts policies containing "func=FILE_CHECK"
rules.
Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>
> ---
> security/integrity/ima/ima_main.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
> index 50b37420ea2c..712c3a522e6c 100644
> --- a/security/integrity/ima/ima_main.c
> +++ b/security/integrity/ima/ima_main.c
> @@ -202,7 +202,8 @@ static void ima_file_free(struct file *file)
> struct inode *inode = file_inode(file);
> struct ima_iint_cache *iint;
>
> - if (!ima_policy_flag || !S_ISREG(inode->i_mode))
> + if (!ima_policy_flag || !S_ISREG(inode->i_mode) ||
> + (file->f_flags & O_PATH))
> return;
>
> iint = ima_iint_find(inode);
> @@ -232,7 +233,8 @@ static int process_measurement(struct file *file, const struct
> cred *cred,
> enum hash_algo hash_algo;
> unsigned int allowed_algos = 0;
>
> - if (!ima_policy_flag || !S_ISREG(inode->i_mode))
> + if (!ima_policy_flag || !S_ISREG(inode->i_mode) ||
> + (file->f_flags & O_PATH))
> return 0;
>
> /* Return an IMA_MEASURE, IMA_APPRAISE, IMA_AUDIT action
next prev parent reply other threads:[~2025-01-16 11:52 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-28 10:06 [PATCH v2 0/7] ima: Remove unnecessary inode locks Roberto Sassu
2024-11-28 10:06 ` [PATCH v2 1/7] fs: ima: Remove S_IMA and IS_IMA() Roberto Sassu
2024-11-28 11:40 ` Jan Kara
2024-11-28 13:30 ` Christian Brauner
2024-11-28 10:06 ` [PATCH v2 2/7] ima: Remove inode lock Roberto Sassu
2025-01-14 13:35 ` Mimi Zohar
2025-01-15 10:45 ` Roberto Sassu
2024-11-28 10:06 ` [PATCH v2 3/7] ima: Ensure lock is held when setting iint pointer in inode security blob Roberto Sassu
2025-01-14 14:20 ` Mimi Zohar
2025-01-15 10:51 ` Roberto Sassu
2024-11-28 10:06 ` [PATCH v2 4/7] ima: Mark concurrent accesses to the iint pointer in the " Roberto Sassu
2025-01-14 14:32 ` Mimi Zohar
2024-11-28 10:06 ` [PATCH v2 5/7] ima: Set security.ima on file close when ima_appraise=fix Roberto Sassu
2025-01-15 13:46 ` Mimi Zohar
2025-01-17 17:06 ` Roberto Sassu
2024-11-28 10:06 ` [PATCH v2 6/7] ima: Discard files opened with O_PATH Roberto Sassu
2024-11-28 16:22 ` Christian Brauner
2024-11-28 16:25 ` Roberto Sassu
2025-01-16 11:52 ` Mimi Zohar [this message]
2024-11-28 10:06 ` [PATCH v2 7/7] ima: Reset IMA_NONACTION_RULE_FLAGS after post_setattr Roberto Sassu
2025-01-16 13:12 ` 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=906089e5f4e24182dc776488959dc595c92a616c.camel@linux.ibm.com \
--to=zohar@linux.ibm.com \
--cc=brauner@kernel.org \
--cc=dmitry.kasatkin@gmail.com \
--cc=eric.snowberg@oracle.com \
--cc=jack@suse.cz \
--cc=jmorris@namei.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=paul@paul-moore.com \
--cc=roberto.sassu@huawei.com \
--cc=roberto.sassu@huaweicloud.com \
--cc=serge@hallyn.com \
--cc=stable@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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).