Skip to content

Commit 3ad49d3

Browse files
Dan Carpentercschaufler
authored andcommitted
smackfs: Prevent underflow in smk_set_cipso()
There is a upper bound to "catlen" but no lower bound to prevent negatives. I don't see that this necessarily causes a problem but we may as well be safe. Fixes: e114e47 ("Smack: Simplified Mandatory Access Control Kernel") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
1 parent c47b658 commit 3ad49d3

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
@@ -896,7 +896,7 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf,
896896
}
897897

898898
ret = sscanf(rule, "%d", &catlen);
899-
if (ret != 1 || catlen > SMACK_CIPSO_MAXCATNUM)
899+
if (ret != 1 || catlen < 0 || catlen > SMACK_CIPSO_MAXCATNUM)
900900
goto out;
901901

902902
if (format == SMK_FIXED24_FMT &&

0 commit comments

Comments
 (0)