From: Greg Kroah-Hartman Date: Tue, 16 Nov 2021 11:19:21 +0000 (+0100) Subject: 5.14-stable patches X-Git-Tag: v5.4.160~13 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=71268d9ee847b0793ebdeeb1eda2309a83ce2ff1;p=thirdparty%2Fkernel%2Fstable-queue.git 5.14-stable patches added patches: ima-reject-unknown-hash-algorithms-in-ima_get_hash_algo.patch --- diff --git a/queue-5.14/ima-reject-unknown-hash-algorithms-in-ima_get_hash_algo.patch b/queue-5.14/ima-reject-unknown-hash-algorithms-in-ima_get_hash_algo.patch new file mode 100644 index 00000000000..5dd12482eef --- /dev/null +++ b/queue-5.14/ima-reject-unknown-hash-algorithms-in-ima_get_hash_algo.patch @@ -0,0 +1,40 @@ +From cb181da161963eddc9de0000de6ab2c7942be219 Mon Sep 17 00:00:00 2001 +From: THOBY Simon +Date: Sun, 22 Aug 2021 08:55:26 +0000 +Subject: IMA: reject unknown hash algorithms in ima_get_hash_algo + +From: THOBY Simon + +commit cb181da161963eddc9de0000de6ab2c7942be219 upstream. + +The new function validate_hash_algo() assumed that ima_get_hash_algo() +always return a valid 'enum hash_algo', but it returned the +user-supplied value present in the digital signature without +any bounds checks. + +Update ima_get_hash_algo() to always return a valid hash algorithm, +defaulting on 'ima_hash_algo' when the user-supplied value inside +the xattr is invalid. + +Signed-off-by: THOBY Simon +Reported-by: syzbot+e8bafe7b82c739eaf153@syzkaller.appspotmail.com +Fixes: 50f742dd9147 ("IMA: block writes of the security.ima xattr with unsupported algorithms") +Reviewed-by: Lakshmi Ramasubramanian +Signed-off-by: Mimi Zohar +Signed-off-by: Greg Kroah-Hartman +--- + security/integrity/ima/ima_appraise.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/security/integrity/ima/ima_appraise.c ++++ b/security/integrity/ima/ima_appraise.c +@@ -184,7 +184,8 @@ enum hash_algo ima_get_hash_algo(const s + switch (xattr_value->type) { + case EVM_IMA_XATTR_DIGSIG: + sig = (typeof(sig))xattr_value; +- if (sig->version != 2 || xattr_len <= sizeof(*sig)) ++ if (sig->version != 2 || xattr_len <= sizeof(*sig) ++ || sig->hash_algo >= HASH_ALGO__LAST) + return ima_hash_algo; + return sig->hash_algo; + break; diff --git a/queue-5.14/series b/queue-5.14/series index 4954f87c731..4f989dadaa2 100644 --- a/queue-5.14/series +++ b/queue-5.14/series @@ -851,3 +851,4 @@ ath10k-fix-invalid-dma_addr_t-token-assignment.patch mmc-moxart-fix-null-pointer-dereference-on-pointer-host.patch selftests-x86-iopl-adjust-to-the-faked-iopl-cli-sti-usage.patch selftests-bpf-fix-also-no-alu32-strobemeta-selftest.patch +ima-reject-unknown-hash-algorithms-in-ima_get_hash_algo.patch