[PATCH 0/4 v3] seccomp: improve handling of SECCOMP_IOCTL_NOTIF_RECV

Andrei Vagin posted 4 patches 1 year, 5 months ago
kernel/exit.c                                 |   3 +-
kernel/seccomp.c                              |  30 +++-
tools/testing/selftests/seccomp/seccomp_bpf.c | 131 ++++++++++++++++++
3 files changed, 157 insertions(+), 7 deletions(-)
[PATCH 0/4 v3] seccomp: improve handling of SECCOMP_IOCTL_NOTIF_RECV
Posted by Andrei Vagin 1 year, 5 months ago
This patch set addresses two problems with the SECCOMP_IOCTL_NOTIF_RECV
ioctl:
* it doesn't return when the seccomp filter becomes unused (all tasks
  have exited).
* EPOLLHUP is triggered not when a task exits, but rather when its zombie
  is collected.

v2: - Remove unnecessary checks of PF_EXITING.
    - Take siglock with disabling irqs.
    Thanks to Oleg for the review and the help with the first version.
v3: - a few fixes suggested by Kees.
    - add a test to ensure that a dead thread leader doesn't prevent
      installing new filters with SECCOMP_FILTER_FLAG_TSYNC.

Andrei Vagin (3):
  seccomp: interrupt SECCOMP_IOCTL_NOTIF_RECV when all users have exited
  seccomp: release task filters when the task exits
  selftests/seccomp: add test for NOTIF_RECV and unused filters
  selftests/seccomp: check that a zombie leader doesn't affect others

 kernel/exit.c                                 |   3 +-
 kernel/seccomp.c                              |  30 +++-
 tools/testing/selftests/seccomp/seccomp_bpf.c | 131 ++++++++++++++++++
 3 files changed, 157 insertions(+), 7 deletions(-)

-- 
2.45.0.rc1.225.g2a3ae87e7f-goog
Re: [PATCH 0/4 v3] seccomp: improve handling of SECCOMP_IOCTL_NOTIF_RECV
Posted by Kees Cook 1 year, 5 months ago
On Fri, 28 Jun 2024 02:10:10 +0000, Andrei Vagin wrote:
> This patch set addresses two problems with the SECCOMP_IOCTL_NOTIF_RECV
> ioctl:
> * it doesn't return when the seccomp filter becomes unused (all tasks
>   have exited).
> * EPOLLHUP is triggered not when a task exits, but rather when its zombie
>   is collected.
> 
> [...]

Applied to for-next/seccomp, thanks!

[1/4] seccomp: interrupt SECCOMP_IOCTL_NOTIF_RECV when all users have exited
      https://git.kernel.org/kees/c/6dbfc08fd57a
[2/4] seccomp: release task filters when the task exits
      https://git.kernel.org/kees/c/13eb42e2529e
[3/4] selftests/seccomp: add test for NOTIF_RECV and unused filters
      https://git.kernel.org/kees/c/9b366d69118b
[4/4] selftests/seccomp: check that a zombie leader doesn't affect others
      https://git.kernel.org/kees/c/22cc0f3b4d0c

Take care,

-- 
Kees Cook
Re: [PATCH 0/4 v3] seccomp: improve handling of SECCOMP_IOCTL_NOTIF_RECV
Posted by Tycho Andersen 1 year, 5 months ago
On Fri, Jun 28, 2024 at 10:38 AM Kees Cook <kees@kernel.org> wrote:
>
> On Fri, 28 Jun 2024 02:10:10 +0000, Andrei Vagin wrote:
> > This patch set addresses two problems with the SECCOMP_IOCTL_NOTIF_RECV
> > ioctl:
> > * it doesn't return when the seccomp filter becomes unused (all tasks
> >   have exited).
> > * EPOLLHUP is triggered not when a task exits, but rather when its zombie
> >   is collected.
> >
> > [...]
>
> Applied to for-next/seccomp, thanks!

A little late to the party, but,

Reviewed-by: Tycho Andersen <tandersen@netflix.com>