The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Mimi Zohar <zohar@linux.ibm.com>
To: Roberto Sassu <roberto.sassu@huaweicloud.com>,
	corbet@lwn.net, 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-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-fsdevel@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 v3 6/6] ima: Reset IMA_NONACTION_RULE_FLAGS after post_setattr
Date: Sun, 02 Feb 2025 20:31:08 -0500	[thread overview]
Message-ID: <e93596a3f7696bfe4912f6ec91152e8969bb1192.camel@linux.ibm.com> (raw)
In-Reply-To: <20250122172432.3074180-7-roberto.sassu@huaweicloud.com>

On Wed, 2025-01-22 at 18:24 +0100, Roberto Sassu wrote:
> From: Roberto Sassu <roberto.sassu@huawei.com>
> 
> Commit 11c60f23ed13 ("integrity: Remove unused macro
> IMA_ACTION_RULE_FLAGS") removed the IMA_ACTION_RULE_FLAGS mask, due to it
> not being used after commit 0d73a55208e9 ("ima: re-introduce own integrity
> cache lock").
> 
> However, it seems that the latter commit mistakenly used the wrong mask
> when moving the code from ima_inode_post_setattr() to process_measurement(). There
> is no mention in the commit message about this
> change and it looks quite important, since changing from IMA_ACTIONS_FLAGS
> (later renamed to IMA_NONACTION_FLAGS) to IMA_ACTION_RULE_FLAGS was done by
> commit 42a4c603198f0 ("ima: fix ima_inode_post_setattr").

Roberto, thank you for the detailed explanation.  Could we summarize the problem as: 

Commit 0d73a55208e9 ("ima: re-introduce own integrity cache lock") mistakenly
reverted the performance improvement introduced in commit 42a4c603198f0 ("ima: fix
ima_inode_post_setattr").  The unused bit mask was subsequently removed by commit
11c60f23ed13 ("integrity: Remove unused macro IMA_ACTION_RULE_FLAGS").

> 
> Restore the original change of resetting only the policy-specific flags and
> not the new file status, but with new mask 0xfb000000 since the
> policy-specific flags changed meanwhile. Also rename IMA_ACTION_RULE_FLAGS
> to IMA_NONACTION_RULE_FLAGS, to be consistent with IMA_NONACTION_FLAGS.

Instead of restoring the bit mask that is used only once, consider inlining the
correct bit mask (e.g. IMA_NONACTION_FLAGS & ~IMA_NEW_FILE) and expanding the
existing comment.

> 
> Cc: stable@vger.kernel.org # v4.16.x
> Fixes: 11c60f23ed13 ("integrity: Remove unused macro IMA_ACTION_RULE_FLAGS")

Please update the Fixes tag to refer to commit 0d73a55208e9.

> Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>
> Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>

> ---
>  security/integrity/ima/ima.h      | 1 +
>  security/integrity/ima/ima_main.c | 2 +-
>  2 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
> index e1a3d1239bee..615900d4150d 100644
> --- a/security/integrity/ima/ima.h
> +++ b/security/integrity/ima/ima.h
> @@ -141,6 +141,7 @@ struct ima_kexec_hdr {
>  
>  /* IMA iint policy rule cache flags */
>  #define IMA_NONACTION_FLAGS	0xff000000
> +#define IMA_NONACTION_RULE_FLAGS	0xfb000000
>  #define IMA_DIGSIG_REQUIRED	0x01000000
>  #define IMA_PERMIT_DIRECTIO	0x02000000
>  #define IMA_NEW_FILE		0x04000000
> diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
> index 46adfd524dd8..7173dca20c23 100644
> --- a/security/integrity/ima/ima_main.c
> +++ b/security/integrity/ima/ima_main.c
> @@ -275,7 +275,7 @@ static int process_measurement(struct file *file, const struct
> cred *cred,
>  		/* reset appraisal flags if ima_inode_post_setattr was called */

Update the comment based on the original commit 42a4c603198f ("ima: fix
ima_inode_post_setattr") patch description.

thanks,

Mimi

>  		iint->flags &= ~(IMA_APPRAISE | IMA_APPRAISED |
>  				 IMA_APPRAISE_SUBMASK | IMA_APPRAISED_SUBMASK |
> -				 IMA_NONACTION_FLAGS);
> +				 IMA_NONACTION_RULE_FLAGS);
>  	/*
>  	 * Re-evaulate the file if either the xattr has changed or the


      reply	other threads:[~2025-02-03  1:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-22 17:24 [PATCH v3 0/6] ima: Remove unnecessary inode locks Roberto Sassu
2025-01-22 17:24 ` [PATCH v3 1/6] fs: ima: Remove S_IMA and IS_IMA() Roberto Sassu
2025-01-31 16:54   ` Mimi Zohar
2025-01-22 17:24 ` [PATCH v3 2/6] ima: Remove inode lock Roberto Sassu
2025-01-31 16:56   ` Mimi Zohar
2025-01-22 17:24 ` [PATCH v3 3/6] ima: Detect if lock is held when iint pointer is set in inode security blob Roberto Sassu
2025-01-31 16:51   ` Mimi Zohar
2025-01-22 17:24 ` [PATCH v3 4/6] ima: Mark concurrent accesses to the iint pointer in the " Roberto Sassu
2025-01-31 16:59   ` Mimi Zohar
2025-01-22 17:24 ` [PATCH v3 5/6] ima: Defer fixing security.ima to __fput() Roberto Sassu
2025-01-31 16:52   ` Mimi Zohar
2025-01-22 17:24 ` [PATCH v3 6/6] ima: Reset IMA_NONACTION_RULE_FLAGS after post_setattr Roberto Sassu
2025-02-03  1:31   ` Mimi Zohar [this message]

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=e93596a3f7696bfe4912f6ec91152e8969bb1192.camel@linux.ibm.com \
    --to=zohar@linux.ibm.com \
    --cc=brauner@kernel.org \
    --cc=corbet@lwn.net \
    --cc=dmitry.kasatkin@gmail.com \
    --cc=eric.snowberg@oracle.com \
    --cc=jack@suse.cz \
    --cc=jmorris@namei.org \
    --cc=linux-doc@vger.kernel.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