Skip to content

Commit cb181da

Browse files
nightmaredmimizohar
authored andcommitted
IMA: reject unknown hash algorithms in ima_get_hash_algo
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 <Simon.THOBY@viveris.fr> Reported-by: syzbot+e8bafe7b82c739eaf153@syzkaller.appspotmail.com Fixes: 50f742d ("IMA: block writes of the security.ima xattr with unsupported algorithms") Reviewed-by: Lakshmi Ramasubramanian <nramas@linux.microsoft.com> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
1 parent d07eeeb commit cb181da

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

security/integrity/ima/ima_appraise.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ enum hash_algo ima_get_hash_algo(const struct evm_ima_xattr_data *xattr_value,
185185
switch (xattr_value->type) {
186186
case EVM_IMA_XATTR_DIGSIG:
187187
sig = (typeof(sig))xattr_value;
188-
if (sig->version != 2 || xattr_len <= sizeof(*sig))
188+
if (sig->version != 2 || xattr_len <= sizeof(*sig)
189+
|| sig->hash_algo >= HASH_ALGO__LAST)
189190
return ima_hash_algo;
190191
return sig->hash_algo;
191192
break;

0 commit comments

Comments
 (0)