All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matt Bobrowski <mattbobrowski@google.com>
To: zohar@linux.ibm.com, dmitry.kasatkin@gmail.com
Cc: linux-integrity@vger.kernel.org
Subject: Re: [PATCH] ima: fix error handling logic when file measurement failed
Date: Sun, 22 Jan 2023 23:41:48 +0000	[thread overview]
Message-ID: <Y83JvB7+IwxqRgMZ@google.com> (raw)
In-Reply-To: <Y7T1eAAVXoZ70MPM@google.com>

Hey Mimi,

Just a gentle ping on this one. 

On Wed, Jan 04, 2023 at 03:41:44AM +0000, Matt Bobrowski wrote:
> Restore the error handling logic so that when file measurement fails,
> the respective iint entry is not left with the digest data being
> populated with zeroes.
> 
> Fixes: 54f03916fb89 ("ima: permit fsverity's file digests in the IMA measurement list")
> Signed-off-by: Matt Bobrowski <mattbobrowski@google.com>
> ---
>  security/integrity/ima/ima_api.c  | 2 +-
>  security/integrity/ima/ima_main.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
> index c1e76282b5ee..1e3a7a4f8833 100644
> --- a/security/integrity/ima/ima_api.c
> +++ b/security/integrity/ima/ima_api.c
> @@ -292,7 +292,7 @@ int ima_collect_measurement(struct integrity_iint_cache *iint,
>  		result = ima_calc_file_hash(file, &hash.hdr);
>  	}
>  
> -	if (result == -ENOMEM)
> +	if (result && result != -EBADF && result != -EINVAL)
>  		goto out;
>  
>  	length = sizeof(hash.hdr) + hash.hdr.length;
> diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
> index 377300973e6c..b1ae0f2751f1 100644
> --- a/security/integrity/ima/ima_main.c
> +++ b/security/integrity/ima/ima_main.c
> @@ -337,7 +337,7 @@ static int process_measurement(struct file *file, const struct cred *cred,
>  	hash_algo = ima_get_hash_algo(xattr_value, xattr_len);
>  
>  	rc = ima_collect_measurement(iint, file, buf, size, hash_algo, modsig);
> -	if (rc == -ENOMEM)
> +	if (rc != 0 && rc != -EBADF && rc != -EINVAL)
>  		goto out_locked;
>  
>  	if (!pathbuf)	/* ima_rdwr_violation possibly pre-fetched */
> -- 
> 2.39.0.314.g84b9a713c41-goog

/M

  reply	other threads:[~2023-01-22 23:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-04  3:41 [PATCH] ima: fix error handling logic when file measurement failed Matt Bobrowski
2023-01-22 23:41 ` Matt Bobrowski [this message]
2023-01-23  0:54   ` Mimi Zohar
2023-01-23  1:25     ` Matt Bobrowski

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=Y83JvB7+IwxqRgMZ@google.com \
    --to=mattbobrowski@google.com \
    --cc=dmitry.kasatkin@gmail.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=zohar@linux.ibm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.