[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200721003830.GC7464@sol.localdomain>
Date: Mon, 20 Jul 2020 17:38:30 -0700
From: Eric Biggers <ebiggers@...nel.org>
To: linux-security-module@...r.kernel.org,
Casey Schaufler <casey@...aufler-ca.com>,
James Morris <jmorris@...ei.org>,
"Serge E . Hallyn" <serge@...lyn.com>
Cc: syzkaller-bugs@...glegroups.com, linux-kernel@...r.kernel.org,
stable@...r.kernel.org,
syzbot+e6416dabb497a650da40@...kaller.appspotmail.com
Subject: Re: [PATCH] Smack: fix use-after-free in smk_write_relabel_self()
On Wed, Jul 08, 2020 at 01:15:20PM -0700, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@...gle.com>
>
> 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@...kaller.appspotmail.com
> Fixes: 38416e53936e ("Smack: limited capability for changing process label")
> Cc: <stable@...r.kernel.org> # v4.4+
> Signed-off-by: Eric Biggers <ebiggers@...gle.com>
Ping.
Powered by blists - more mailing lists