Skip to content

Commit 84e99e5

Browse files
committed
Smack: slab-out-of-bounds in vsscanf
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]>
1 parent 092c94a commit 84e99e5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

security/smack/smackfs.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,11 +878,21 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf,
878878
else
879879
rule += strlen(skp->smk_known) + 1;
880880

881+
if (rule > data + count) {
882+
rc = -EOVERFLOW;
883+
goto out;
884+
}
885+
881886
ret = sscanf(rule, "%d", &maplevel);
882887
if (ret != 1 || maplevel > SMACK_CIPSO_MAXLEVEL)
883888
goto out;
884889

885890
rule += SMK_DIGITLEN;
891+
if (rule > data + count) {
892+
rc = -EOVERFLOW;
893+
goto out;
894+
}
895+
886896
ret = sscanf(rule, "%d", &catlen);
887897
if (ret != 1 || catlen > SMACK_CIPSO_MAXCATNUM)
888898
goto out;

0 commit comments

Comments
 (0)