diff options
author | Tycho Andersen <tycho@tycho.pizza> | 2020-09-02 04:40:16 +0300 |
---|---|---|
committer | Kees Cook <keescook@chromium.org> | 2020-09-08 21:19:50 +0300 |
commit | a566a9012acd7c9a4be7e30dc7acb7a811ec2260 (patch) | |
tree | eaf1faa6cece4d4ba2d24192d6bf9cf633f47a44 /kernel/cpu_pm.c | |
parent | d012a7190fc1fd72ed48911e77ca97ba4521bccd (diff) | |
download | linux-a566a9012acd7c9a4be7e30dc7acb7a811ec2260.tar.xz |
seccomp: don't leak memory when filter install races
In seccomp_set_mode_filter() with TSYNC | NEW_LISTENER, we first initialize
the listener fd, then check to see if we can actually use it later in
seccomp_may_assign_mode(), which can fail if anyone else in our thread
group has installed a filter and caused some divergence. If we can't, we
partially clean up the newly allocated file: we put the fd, put the file,
but don't actually clean up the *memory* that was allocated at
filter->notif. Let's clean that up too.
To accomplish this, let's hoist the actual "detach a notifier from a
filter" code to its own helper out of seccomp_notify_release(), so that in
case anyone adds stuff to init_listener(), they only have to add the
cleanup code in one spot. This does a bit of extra locking and such on the
failure path when the filter is not attached, but it's a slow failure path
anyway.
Fixes: 51891498f2da ("seccomp: allow TSYNC and USER_NOTIF together")
Reported-by: syzbot+3ad9614a12f80994c32e@syzkaller.appspotmail.com
Signed-off-by: Tycho Andersen <tycho@tycho.pizza>
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Link: https://lore.kernel.org/r/20200902014017.934315-1-tycho@tycho.pizza
Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'kernel/cpu_pm.c')
0 files changed, 0 insertions, 0 deletions