linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lakshmi Ramasubramanian <nramas@linux.microsoft.com>
To: Roberto Sassu <roberto.sassu@huawei.com>,
	zohar@linux.ibm.com, paul@paul-moore.com
Cc: stephen.smalley.work@gmail.com, prsriva02@gmail.com,
	tusharsu@linux.microsoft.com, linux-integrity@vger.kernel.org,
	linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org, selinux@vger.kernel.org
Subject: Re: [PATCH v2 1/3] ima: Introduce ima_get_current_hash_algo()
Date: Thu, 1 Jul 2021 09:01:06 -0700	[thread overview]
Message-ID: <6c970b4a-08dd-adc2-6570-3d9aa823f88e@linux.microsoft.com> (raw)
In-Reply-To: <20210701125552.2958008-2-roberto.sassu@huawei.com>

On 7/1/2021 5:55 AM, Roberto Sassu wrote:
> This patch introduces the new function ima_get_current_hash_algo(), that
> callers in the other kernel subsystems might use to obtain the hash
> algorithm selected by IMA.
> 
> Its primary use will be to determine which algorithm has been used to
> calculate the digest written by ima_measure_critical_data() to the location
> passed as a new parameter (in a subsequent patch). >
> Since the hash algorithm does not change after the IMA setup phase, there
> is no risk of races (obtaining a digest calculated with a different
> algorithm than the one returned).

Reviewed-by: Lakshmi Ramasubramanian <nramas@linux.microsoft.com>

  -lakshmi

> Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
> ---
>   include/linux/ima.h               | 7 +++++++
>   security/integrity/ima/ima_main.c | 5 +++++
>   2 files changed, 12 insertions(+)
> 
> diff --git a/include/linux/ima.h b/include/linux/ima.h
> index 61d5723ec303..81e830d01ced 100644
> --- a/include/linux/ima.h
> +++ b/include/linux/ima.h
> @@ -11,9 +11,11 @@
>   #include <linux/fs.h>
>   #include <linux/security.h>
>   #include <linux/kexec.h>
> +#include <crypto/hash_info.h>
>   struct linux_binprm;
>   
>   #ifdef CONFIG_IMA
> +extern enum hash_algo ima_get_current_hash_algo(void);
>   extern int ima_bprm_check(struct linux_binprm *bprm);
>   extern int ima_file_check(struct file *file, int mask);
>   extern void ima_post_create_tmpfile(struct user_namespace *mnt_userns,
> @@ -64,6 +66,11 @@ static inline const char * const *arch_get_ima_policy(void)
>   #endif
>   
>   #else
> +static inline enum hash_algo ima_get_current_hash_algo(void)
> +{
> +	return HASH_ALGO__LAST;
> +}
> +
>   static inline int ima_bprm_check(struct linux_binprm *bprm)
>   {
>   	return 0;
> diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
> index 287b90509006..8ef1fa357e0c 100644
> --- a/security/integrity/ima/ima_main.c
> +++ b/security/integrity/ima/ima_main.c
> @@ -76,6 +76,11 @@ static int __init hash_setup(char *str)
>   }
>   __setup("ima_hash=", hash_setup);
>   
> +enum hash_algo ima_get_current_hash_algo(void)
> +{
> +	return ima_hash_algo;
> +}
> +
>   /* Prevent mmap'ing a file execute that is already mmap'ed write */
>   static int mmap_violation_check(enum ima_hooks func, struct file *file,
>   				char **pathbuf, const char **pathname,
> 

  reply	other threads:[~2021-07-01 15:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-01 12:55 [PATCH v2 0/3] ima: Provide more info about buffer measurement Roberto Sassu
2021-07-01 12:55 ` [PATCH v2 1/3] ima: Introduce ima_get_current_hash_algo() Roberto Sassu
2021-07-01 16:01   ` Lakshmi Ramasubramanian [this message]
2021-07-01 12:55 ` [PATCH v2 2/3] ima: Return int in the functions to measure a buffer Roberto Sassu
2021-07-01 16:15   ` Lakshmi Ramasubramanian
2021-07-02 10:51     ` Roberto Sassu
2021-07-01 12:55 ` [PATCH v2 3/3] ima: Add digest and digest_len params to " Roberto Sassu
2021-07-01 17:27   ` Lakshmi Ramasubramanian
2021-07-02 10:54     ` Roberto Sassu

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=6c970b4a-08dd-adc2-6570-3d9aa823f88e@linux.microsoft.com \
    --to=nramas@linux.microsoft.com \
    --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=prsriva02@gmail.com \
    --cc=roberto.sassu@huawei.com \
    --cc=selinux@vger.kernel.org \
    --cc=stephen.smalley.work@gmail.com \
    --cc=tusharsu@linux.microsoft.com \
    --cc=zohar@linux.ibm.com \
    --subject='Re: [PATCH v2 1/3] ima: Introduce ima_get_current_hash_algo()' \
    /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

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).