]> git.baikalelectronics.ru Git - kernel.git/commit
seccomp: fix UAF in user-trap code
authorTycho Andersen <tycho@tycho.ws>
Sat, 12 Jan 2019 18:24:20 +0000 (11:24 -0700)
committerJames Morris <james.morris@microsoft.com>
Tue, 15 Jan 2019 17:43:12 +0000 (09:43 -0800)
commit921b64a765fe99ef36d64a24f004e57a8591d575
tree56144b909f723d0bf4365c2ccbd8ec2e24d9907d
parentd748cbd38327b3fe3d021f2f1d72d290039b6e89
seccomp: fix UAF in user-trap code

On the failure path, we do an fput() of the listener fd if the filter fails
to install (e.g. because of a TSYNC race that's lost, or if the thread is
killed, etc.). fput() doesn't actually release the fd, it just ads it to a
work queue. Then the thread proceeds to free the filter, even though the
listener struct file has a reference to it.

To fix this, on the failure path let's set the private data to null, so we
know in ->release() to ignore the filter.

Reported-by: syzbot+981c26489b2d1c6316ba@syzkaller.appspotmail.com
Fixes: 6a02b13b4538 ("seccomp: add a return code to trap to userspace")
Signed-off-by: Tycho Andersen <tycho@tycho.ws>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: James Morris <james.morris@microsoft.com>
kernel/seccomp.c