Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ima: fix cred sparse warning

Fix ima_policy.c sparse "warning: dereference of noderef expression"
message, by accessing cred->uid using current_cred().

Changelog v1:
- Change __cred to just cred (based on David Howell's comment)

Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
Signed-off-by: James Morris <jmorris@namei.org>

authored by

Mimi Zohar and committed by
James Morris
3db59dd9 4bf1924c

+2 -1
+2 -1
security/integrity/ima/ima_policy.c
··· 99 99 struct inode *inode, enum ima_hooks func, int mask) 100 100 { 101 101 struct task_struct *tsk = current; 102 + const struct cred *cred = current_cred(); 102 103 int i; 103 104 104 105 if ((rule->flags & IMA_FUNC) && rule->func != func) ··· 109 108 if ((rule->flags & IMA_FSMAGIC) 110 109 && rule->fsmagic != inode->i_sb->s_magic) 111 110 return false; 112 - if ((rule->flags & IMA_UID) && rule->uid != tsk->cred->uid) 111 + if ((rule->flags & IMA_UID) && rule->uid != cred->uid) 113 112 return false; 114 113 for (i = 0; i < MAX_LSM_RULES; i++) { 115 114 int rc = 0;