Skip to content
Commit dfe719fe authored by Jann Horn's avatar Jann Horn Committed by Kees Cook
Browse files

seccomp: Make duplicate listener detection non-racy



Currently, init_listener() tries to prevent adding a filter with
SECCOMP_FILTER_FLAG_NEW_LISTENER if one of the existing filters already
has a listener. However, this check happens without holding any lock that
would prevent another thread from concurrently installing a new filter
(potentially with a listener) on top of the ones we already have.

Theoretically, this is also a data race: The plain load from
current->seccomp.filter can race with concurrent writes to the same
location.

Fix it by moving the check into the region that holds the siglock to guard
against concurrent TSYNC.

(The "Fixes" tag points to the commit that introduced the theoretical
data race; concurrent installation of another filter with TSYNC only
became possible later, in commit 51891498 ("seccomp: allow TSYNC and
USER_NOTIF together").)

Fixes: 6a21cc50 ("seccomp: add a return code to trap to userspace")
Reviewed-by: default avatarTycho Andersen <tycho@tycho.pizza>
Signed-off-by: default avatarJann Horn <jannh@google.com>
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20201005014401.490175-1-jannh@google.com
parent 282a181b
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment