summaryrefslogtreecommitdiffstats
path: root/security/smack
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2020-07-23 17:22:19 +0200
committerCasey Schaufler <casey@schaufler-ca.com>2020-07-27 22:35:03 +0200
commita6bd4f6d9b07452b0b19842044a6c3ea384b0b88 (patch)
tree0f8604f6e759a170eb0e6c5e8e25edd9b0fbc231 /security/smack
parentSmack: fix use-after-free in smk_write_relabel_self() (diff)
downloadlinux-a6bd4f6d9b07452b0b19842044a6c3ea384b0b88.tar.xz
linux-a6bd4f6d9b07452b0b19842044a6c3ea384b0b88.zip
Smack: fix another vsscanf out of bounds
This is similar to commit 84e99e58e8d1 ("Smack: slab-out-of-bounds in vsscanf") where we added a bounds check on "rule". Reported-by: syzbot+a22c6092d003d6fe1122@syzkaller.appspotmail.com Fixes: f7112e6c9abf ("Smack: allow for significantly longer Smack labels v4") 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.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
index 840a192e9337..2bae1fc493d1 100644
--- a/security/smack/smackfs.c
+++ b/security/smack/smackfs.c
@@ -905,6 +905,10 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf,
for (i = 0; i < catlen; i++) {
rule += SMK_DIGITLEN;
+ if (rule > data + count) {
+ rc = -EOVERFLOW;
+ goto out;
+ }
ret = sscanf(rule, "%u", &cat);
if (ret != 1 || cat > SMACK_CIPSO_MAXCATNUM)
goto out;