Skip to content

Commit b2b8438

Browse files
Dan Carpentergregkh
authored andcommitted
Smack: prevent underflow in smk_set_cipso()
[ Upstream commit 42a2df3 ] 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 <dan.carpenter@oracle.com> Signed-off-by: Casey Schaufler <casey@schaufler-ca.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 6749926 commit b2b8438

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎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)