Commit bfdd5aaa authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'Smack-for-5.9' of git://github.com/cschaufler/smack-next

Pull smack updates from Casey Schaufler:
 "Minor fixes to Smack for the v5.9 release.

  All were found by automated checkers and have straightforward
  resolution"

* tag 'Smack-for-5.9' of git://github.com/cschaufler/smack-next:
  Smack: prevent underflow in smk_set_cipso()
  Smack: fix another vsscanf out of bounds
  Smack: fix use-after-free in smk_write_relabel_self()
parents b62e4197 42a2df3e
...@@ -884,7 +884,7 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf, ...@@ -884,7 +884,7 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf,
} }
ret = sscanf(rule, "%d", &maplevel); ret = sscanf(rule, "%d", &maplevel);
if (ret != 1 || maplevel > SMACK_CIPSO_MAXLEVEL) if (ret != 1 || maplevel < 0 || maplevel > SMACK_CIPSO_MAXLEVEL)
goto out; goto out;
rule += SMK_DIGITLEN; rule += SMK_DIGITLEN;
...@@ -905,6 +905,10 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf, ...@@ -905,6 +905,10 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf,
for (i = 0; i < catlen; i++) { for (i = 0; i < catlen; i++) {
rule += SMK_DIGITLEN; rule += SMK_DIGITLEN;
if (rule > data + count) {
rc = -EOVERFLOW;
goto out;
}
ret = sscanf(rule, "%u", &cat); ret = sscanf(rule, "%u", &cat);
if (ret != 1 || cat > SMACK_CIPSO_MAXCATNUM) if (ret != 1 || cat > SMACK_CIPSO_MAXCATNUM)
goto out; goto out;
...@@ -2720,7 +2724,6 @@ static int smk_open_relabel_self(struct inode *inode, struct file *file) ...@@ -2720,7 +2724,6 @@ static int smk_open_relabel_self(struct inode *inode, struct file *file)
static ssize_t smk_write_relabel_self(struct file *file, const char __user *buf, static ssize_t smk_write_relabel_self(struct file *file, const char __user *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct task_smack *tsp = smack_cred(current_cred());
char *data; char *data;
int rc; int rc;
LIST_HEAD(list_tmp); LIST_HEAD(list_tmp);
...@@ -2745,11 +2748,21 @@ static ssize_t smk_write_relabel_self(struct file *file, const char __user *buf, ...@@ -2745,11 +2748,21 @@ static ssize_t smk_write_relabel_self(struct file *file, const char __user *buf,
kfree(data); kfree(data);
if (!rc || (rc == -EINVAL && list_empty(&list_tmp))) { if (!rc || (rc == -EINVAL && list_empty(&list_tmp))) {
struct cred *new;
struct task_smack *tsp;
new = prepare_creds();
if (!new) {
rc = -ENOMEM;
goto out;
}
tsp = smack_cred(new);
smk_destroy_label_list(&tsp->smk_relabel); smk_destroy_label_list(&tsp->smk_relabel);
list_splice(&list_tmp, &tsp->smk_relabel); list_splice(&list_tmp, &tsp->smk_relabel);
commit_creds(new);
return count; return count;
} }
out:
smk_destroy_label_list(&list_tmp); smk_destroy_label_list(&list_tmp);
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment