From: THOBY Simon <Simon.THOBY@viveris.fr>
To: "zohar@linux.ibm.com" <zohar@linux.ibm.com>,
"dmitry.kasatkin@gmail.com" <dmitry.kasatkin@gmail.com>,
"linux-integrity@vger.kernel.org"
<linux-integrity@vger.kernel.org>,
BARVAUX Didier <Didier.BARVAUX@viveris.fr>
Cc: THOBY Simon <Simon.THOBY@viveris.fr>
Subject: [PATCH v8 6/6] IMA: prevent SETXATTR_CHECK policy rules with unavailable algorithms
Date: Mon, 16 Aug 2021 08:11:01 +0000 [thread overview]
Message-ID: <20210816081056.24530-7-Simon.THOBY@viveris.fr> (raw)
In-Reply-To: <20210816081056.24530-1-Simon.THOBY@viveris.fr>
SETXATTR_CHECK poliy rules assume that any algorithm listed in the
'appraise_algos' flag must be accepted when performing setxattr()
on the security.ima xattr.
However nothing checks that they are available in the current kernel.
A userland application could hash a file with a digest that the kernel
wouldn't be able to verify. However, if SETXATTR_CHECK is not in use,
the kernel already forbids that xattr write.
Verify that algorithms listed in appraise_algos are available to the
current kernel and reject the policy update otherwise. This will fix
the inconsistency between SETXATTR_CHECK and non-SETXATTR_CHECK
behaviors.
That filtering is only performed in ima_parse_appraise_algos() when
updating policies so that we do not have to pay the price of allocating
a hash object every time validate_hash_algo() is called in
ima_inode_setxattr().
Signed-off-by: THOBY Simon <Simon.THOBY@viveris.fr>
---
security/integrity/ima/ima_policy.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
index 9eaa509f487a..87b9b71cb820 100644
--- a/security/integrity/ima/ima_policy.c
+++ b/security/integrity/ima/ima_policy.c
@@ -1258,6 +1258,12 @@ static unsigned int ima_parse_appraise_algos(char *arg)
return 0;
}
+ if (!crypto_has_alg(hash_algo_name[idx], 0, 0)) {
+ pr_err("unavailable hash algorithm \"%s\", check your kernel configuration",
+ token);
+ return 0;
+ }
+
/* Add the hash algorithm to the 'allowed' bitfield */
res |= (1U << idx);
}
--
2.31.1
next prev parent reply other threads:[~2021-08-16 8:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-16 8:10 [PATCH v8 0/6] IMA: restrict the accepted digest algorithms for the security.ima xattr THOBY Simon
2021-08-16 8:10 ` [PATCH v8 2/6] IMA: block writes of the security.ima xattr with unsupported algorithms THOBY Simon
2021-08-16 8:10 ` [PATCH v8 1/6] IMA: remove the dependency on CRYPTO_MD5 THOBY Simon
2021-08-16 8:11 ` [PATCH v8 3/6] IMA: add support to restrict the hash algorithms used for file appraisal THOBY Simon
2021-08-16 8:11 ` [PATCH v8 4/6] IMA: add a policy option to restrict xattr hash algorithms on appraisal THOBY Simon
2021-08-16 8:11 ` THOBY Simon [this message]
2021-08-16 22:20 ` [PATCH v8 6/6] IMA: prevent SETXATTR_CHECK policy rules with unavailable algorithms Mimi Zohar
2021-08-17 6:44 ` THOBY Simon
2021-08-16 8:11 ` [PATCH v8 5/6] IMA: introduce a new policy option func=SETXATTR_CHECK THOBY Simon
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=20210816081056.24530-7-Simon.THOBY@viveris.fr \
--to=simon.thoby@viveris.fr \
--cc=Didier.BARVAUX@viveris.fr \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox