summaryrefslogtreecommitdiff
path: root/security
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@linaro.org>2023-07-06 08:52:39 +0300
committerCasey Schaufler <casey@schaufler-ca.com>2023-08-07 14:09:23 -0700
commit3ad49d37cf5759c3b8b68d02e3563f633d9c1aee (patch)
tree1c1ce8e2546ca1d443aed397d939b92efd3c2b84 /security
parentc47b65840024153f6a1c931d6c7c772b3482a0a4 (diff)
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: e114e473771c ("Smack: Simplified Mandatory Access Control Kernel") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Diffstat (limited to 'security')
-rw-r--r--security/smack/smackfs.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
index 2b79c30d4bb6..e22aad7604e8 100644
--- a/security/smack/smackfs.c
+++ b/security/smack/smackfs.c
@@ -896,7 +896,7 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf,
}
ret = sscanf(rule, "%d", &catlen);
- if (ret != 1 || catlen > SMACK_CIPSO_MAXCATNUM)
+ if (ret != 1 || catlen < 0 || catlen > SMACK_CIPSO_MAXCATNUM)
goto out;
if (format == SMK_FIXED24_FMT &&