Skip to content

Commit 42a2df3

Browse files
Dan Carpentercschaufler
authored andcommitted
Smack: prevent underflow in smk_set_cipso()
We have an upper bound on "maplevel" but forgot to check for negative values. Fixes: e114e47 ("Smack: Simplified Mandatory Access Control Kernel") Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Casey Schaufler <[email protected]>
1 parent a6bd4f6 commit 42a2df3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

security/smack/smackfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf,
884884
}
885885

886886
ret = sscanf(rule, "%d", &maplevel);
887-
if (ret != 1 || maplevel > SMACK_CIPSO_MAXLEVEL)
887+
if (ret != 1 || maplevel < 0 || maplevel > SMACK_CIPSO_MAXLEVEL)
888888
goto out;
889889

890890
rule += SMK_DIGITLEN;

0 commit comments

Comments
 (0)