diff options
author | Eric Biggers <ebiggers@google.com> | 2020-07-08 22:15:20 +0200 |
---|---|---|
committer | Casey Schaufler <casey@schaufler-ca.com> | 2020-07-14 20:19:58 +0200 |
commit | beb4ee6770a89646659e6a2178538d2b13e2654e (patch) | |
tree | 696114e949661e6ee6fe7ec0ddc5e04603ed44ba /security/Kconfig.hardening | |
parent | Linux 5.8-rc1 (diff) | |
download | linux-beb4ee6770a89646659e6a2178538d2b13e2654e.tar.xz linux-beb4ee6770a89646659e6a2178538d2b13e2654e.zip |
Smack: fix use-after-free in smk_write_relabel_self()
smk_write_relabel_self() frees memory from the task's credentials with
no locking, which can easily cause a use-after-free because multiple
tasks can share the same credentials structure.
Fix this by using prepare_creds() and commit_creds() to correctly modify
the task's credentials.
Reproducer for "BUG: KASAN: use-after-free in smk_write_relabel_self":
#include <fcntl.h>
#include <pthread.h>
#include <unistd.h>
static void *thrproc(void *arg)
{
int fd = open("/sys/fs/smackfs/relabel-self", O_WRONLY);
for (;;) write(fd, "foo", 3);
}
int main()
{
pthread_t t;
pthread_create(&t, NULL, thrproc, NULL);
thrproc(NULL);
}
Reported-by: syzbot+e6416dabb497a650da40@syzkaller.appspotmail.com
Fixes: 38416e53936e ("Smack: limited capability for changing process label")
Cc: <stable@vger.kernel.org> # v4.4+
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Diffstat (limited to 'security/Kconfig.hardening')
0 files changed, 0 insertions, 0 deletions