summaryrefslogtreecommitdiffstats
path: root/security/smack
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2020-07-23 17:23:05 +0200
committerCasey Schaufler <casey@schaufler-ca.com>2020-07-27 22:35:12 +0200
commit42a2df3e829f3c5562090391b33714b2e2e5ad4a (patch)
tree673418527d96c2f8fc17db77214bd477b4cc0e92 /security/smack
parentSmack: fix another vsscanf out of bounds (diff)
downloadlinux-42a2df3e829f3c5562090391b33714b2e2e5ad4a.tar.xz
linux-42a2df3e829f3c5562090391b33714b2e2e5ad4a.zip
Smack: prevent underflow in smk_set_cipso()
We have an upper bound on "maplevel" but forgot to check for negative values. Fixes: e114e473771c ("Smack: Simplified Mandatory Access Control Kernel") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Diffstat (limited to 'security/smack')
-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 2bae1fc493d1..9c4308077574 100644
--- a/security/smack/smackfs.c
+++ b/security/smack/smackfs.c
@@ -884,7 +884,7 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf,
}
ret = sscanf(rule, "%d", &maplevel);
- if (ret != 1 || maplevel > SMACK_CIPSO_MAXLEVEL)
+ if (ret != 1 || maplevel < 0 || maplevel > SMACK_CIPSO_MAXLEVEL)
goto out;
rule += SMK_DIGITLEN;