Skip to content

Commit

Permalink
Smack: slab-out-of-bounds in vsscanf
Browse files Browse the repository at this point in the history
Add barrier to soob. Return -EOVERFLOW if the buffer
is exceeded.

Suggested-by: Hillf Danton <[email protected]>
Reported-by: [email protected]
Signed-off-by: Casey Schaufler <[email protected]>
  • Loading branch information
cschaufler committed May 6, 2020
1 parent 092c94a commit 84e99e5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions security/smack/smackfs.c
Original file line number Diff line number Diff line change
@@ -878,11 +878,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;

0 comments on commit 84e99e5

Please sign in to comment.