From: Mimi Zohar <zohar@linux.ibm.com>
To: "Jérémy Jean" <Jeremy.Jean@oss.cyber.gouv.fr>,
"Roberto Sassu" <roberto.sassu@huawei.com>,
"Dmitry Kasatkin" <dmitry.kasatkin@gmail.com>
Cc: Eric Snowberg <eric.snowberg@oracle.com>,
linux-integrity@vger.kernel.org,
linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v3 1/2] ima: discard modsig when detached data cannot be supplied
Date: Fri, 23 Oct 2026 13:34:49 -0400 [thread overview]
Message-ID: <fbad99bc209f1c56568d99838a4fca0ce8f63450.camel@linux.ibm.com> (raw)
In-Reply-To: <20261021210145.1851396-4-Jeremy.Jean@oss.cyber.gouv.fr>
On Wed, 2026-10-21 at 21:01 +0000, Jérémy Jean wrote:
> ima_collect_modsig() supplies the file contents to the parsed PKCS#7
> message as detached data. If the message already contains embedded data,
> pkcs7_supply_detached_data() returns -EINVAL, but IMA ignores the error.
> ima_modsig_verify() then verifies the embedded data instead of the file
> being appraised.
>
> Make ima_collect_modsig() report whether the file data was supplied,
> and discard the modsig if it was not.
>
> Fixes: 15588227e086 ("ima: Collect modsig")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
> ---
[...]
>
> diff --git a/security/integrity/ima/ima_modsig.c b/security/integrity/ima/ima_modsig.c
> index 632c746fd81e..f73d6f1b71c0 100644
> --- a/security/integrity/ima/ima_modsig.c
> +++ b/security/integrity/ima/ima_modsig.c
> @@ -96,8 +96,12 @@ int ima_read_modsig(enum ima_hooks func, const void *buf, loff_t buf_len,
> * Since the modsig is part of the file contents, the hash used in its signature
> * isn't the same one ordinarily calculated by IMA. Therefore PKCS7 code
> * calculates a separate one for signature verification.
> + *
> + * Digest export is best-effort; not all signatures expose a single digest.
> + *
> + * Return: true if the file data was supplied, false otherwise.
> */
> -void ima_collect_modsig(struct modsig *modsig, const void *buf, loff_t size)
> +bool ima_collect_modsig(struct modsig *modsig, const void *buf, loff_t size)
> {
> int rc;
>
> @@ -109,11 +113,13 @@ void ima_collect_modsig(struct modsig *modsig, const void *buf, loff_t size)
> sizeof(struct module_signature);
> rc = pkcs7_supply_detached_data(modsig->pkcs7_msg, buf, size);
> if (rc)
> - return;
> + return false;
> +
> + /* Digest export failure does not preclude signature verification. */
> + pkcs7_get_digest(modsig->pkcs7_msg, &modsig->digest,
> + &modsig->digest_size, &modsig->hash_algo);
This change isn't mentioned in the patch description. Is it necessary to
address the bug and be backported?
Mimi
>
> - /* Ask the PKCS7 code to calculate the file hash. */
> - rc = pkcs7_get_digest(modsig->pkcs7_msg, &modsig->digest,
> - &modsig->digest_size, &modsig->hash_algo);
> + return true;
> }
>
> int ima_modsig_verify(struct key *keyring, const struct modsig *modsig)
> diff --git a/security/integrity/ima/ima_template_lib.c b/security/integrity/ima/ima_template_lib.c
> index 8a89236f926c..1be78612394a 100644
> --- a/security/integrity/ima/ima_template_lib.c
> +++ b/security/integrity/ima/ima_template_lib.c
> @@ -478,8 +478,8 @@ int ima_eventdigest_modsig_init(struct ima_event_data *event_data,
> if (rc)
> return rc;
> else if (hash_algo == HASH_ALGO__LAST || cur_digestsize == 0)
> - /* There was some error collecting the digest. */
> - return -EINVAL;
> + /* Keep the ordinary measurement without an exported digest. */
> + return 0;
> }
>
> return ima_eventdigest_init_common(cur_digest, cur_digestsize,
next prev parent reply other threads:[~2026-10-23 17:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 21:01 [PATCH v3 0/2] ima: reject " Jérémy Jean
2026-10-21 21:01 ` [PATCH v3 1/2] ima: discard " Jérémy Jean
2026-10-23 17:34 ` Mimi Zohar [this message]
2026-10-21 21:01 ` [PATCH v3 2/2] ima: audit failure to supply detached data for modsig Jérémy Jean
2026-10-23 17:36 ` Mimi Zohar
2026-10-24 9:40 ` Jérémy Jean
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=fbad99bc209f1c56568d99838a4fca0ce8f63450.camel@linux.ibm.com \
--to=zohar@linux.ibm.com \
--cc=Jeremy.Jean@oss.cyber.gouv.fr \
--cc=dmitry.kasatkin@gmail.com \
--cc=eric.snowberg@oracle.com \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=roberto.sassu@huawei.com \
--cc=stable@vger.kernel.org \
/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
all inboxes | Powered by JetHome®