blob: 0e5c4be708bb2fb61cf7ebbb14bfab18d054d60e [file] [log] [blame]
From 0f16069ef2c77b00e2359eed51e66c889dd8ab68 Mon Sep 17 00:00:00 2001
From: Casey Schaufler <casey@schaufler-ca.com>
Date: Thu, 9 Apr 2020 16:35:28 -0700
Subject: [PATCH] Smack: slab-out-of-bounds in vsscanf
commit 84e99e58e8d1e26f04c097f4266e431a33987f36 upstream.
Add barrier to soob. Return -EOVERFLOW if the buffer
is exceeded.
Suggested-by: Hillf Danton <hdanton@sina.com>
Reported-by: syzbot+bfdd4a2f07be52351350@syzkaller.appspotmail.com
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
index ef0d8712d318..20de7f1f1f41 100644
--- a/security/smack/smackfs.c
+++ b/security/smack/smackfs.c
@@ -877,11 +877,21 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf,
else
rule += strlen(skp->smk_known) + 1;
+ if (rule > data + count) {
+ rc = -EOVERFLOW;
+ goto out;
+ }
+
ret = sscanf(rule, "%d", &maplevel);
if (ret != 1 || maplevel > SMACK_CIPSO_MAXLEVEL)
goto out;
rule += SMK_DIGITLEN;
+ if (rule > data + count) {
+ rc = -EOVERFLOW;
+ goto out;
+ }
+
ret = sscanf(rule, "%d", &catlen);
if (ret != 1 || catlen > SMACK_CIPSO_MAXCATNUM)
goto out;
--
2.27.0