BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jamie Hill-Daniel" <clubby789@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH RESEND 1/2] seccomp: Allow using `SECCOMP_MODE_STRICT` with `SECCOMP_MODE_FILTER`
Date: Tue, 26 May 2026 16:23:11 +0000	[thread overview]
Message-ID: <20260526162312.44C1F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260526-seccomp-combined-v1-1-304b1cc3ad24@hill-daniel.co.uk>

Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
- [High] SECCOMP_MODE_COMBINED allows a ptracer to completely bypass strict mode restrictions via system call manipulation.
- [High] The internal SECCOMP_MODE_COMBINED constant is leaked to userspace, violating ABI stability.
- [High] Checkpoint/Restore (CRIU) and Ptrace filter dumping are broken for processes in COMBINED mode.
- [High] Thread synchronization (TSYNC) is broken and causes state inconsistencies for processes in COMBINED mode.
- [Medium] The transition from SECCOMP_MODE_STRICT to SECCOMP_MODE_COMBINED is structurally unreachable.
--

commit c1df2665317e85f0cd779f5b52a0ed4763185a42
Author: Jamie Hill-Daniel <clubby789@gmail.com>

seccomp: Allow using SECCOMP_MODE_STRICT with SECCOMP_MODE_FILTER

It is currently impossible to enable SECCOMP_MODE_STRICT if
SECCOMP_MODE_FILTER is enabled, and vice-versa. This makes using
seccomp difficult in environments such as Docker, which installs a
seccomp filter by default.

Introduce a new internal SECCOMP_MODE_COMBINED
that runs strict checks, followed by any installed filters.

Link: https://github.com/moby/moby/issues/42082

> diff --git a/kernel/seccomp.c b/kernel/seccomp.c
> index 25f62867a16d9..8201a050d358f 100644
> --- a/kernel/seccomp.c
> +++ b/kernel/seccomp.c
> @@ -33,6 +33,8 @@
>  
>  /* Not exposed in headers: strictly internal use only. */
>  #define SECCOMP_MODE_DEAD	(SECCOMP_MODE_FILTER + 1)
> +/* Run SECCOMP_MODE_STRICT checks, followed by SECCOMP_MODE_FILTER  */
> +#define SECCOMP_MODE_COMBINED (SECCOMP_MODE_DEAD + 1)

[Severity: High]
Does this new internal mode leak to userspace and break ABI expectations?

Looking at prctl_get_seccomp(), it returns current->seccomp.mode directly.
This will now return 4 to userspace for tasks in combined mode, but userspace
utilities like systemd and container runtimes strictly expect the mode to be
0 (DISABLED), 1 (STRICT), or 2 (FILTER).

[Severity: High]
Will setting current->seccomp.mode to SECCOMP_MODE_COMBINED break thread
synchronization (TSYNC)?

seccomp_can_sync_threads() validates sibling threads and only allows
synchronization if they are in SECCOMP_MODE_DISABLED or
SECCOMP_MODE_FILTER. If any thread is in SECCOMP_MODE_COMBINED, this
validation unconditionally fails and SECCOMP_FILTER_FLAG_TSYNC operations
abort with -ESRCH.

[Severity: High]
Can this new mode prevent checkpoint/restore (CRIU) and ptrace filter
dumping?

get_nth_filter(), which is the backend for PTRACE_SECCOMP_GET_FILTER and
seccomp metadata inspection, explicitly enforces the condition:

    if (task->seccomp.mode != SECCOMP_MODE_FILTER)
        return ERR_PTR(-EINVAL);

When a process runs in SECCOMP_MODE_COMBINED, this validation will fail,
making it impossible to inspect, dump, or checkpoint the attached seccomp
BPF filters.

[ ... ]

> @@ -432,14 +434,21 @@ static u32 seccomp_run_filters(const struct seccomp_data *sd,
>  }
>  #endif /* CONFIG_SECCOMP_FILTER */
>  
> -static inline bool seccomp_may_assign_mode(unsigned long seccomp_mode)
> +/**
> + * seccomp_needs_combined: internal function for checking if requested mode
> + * needs to be upgraded to SECCOMP_MODE_COMBINED.
> + *
> + */
> +static inline bool seccomp_needs_combined(unsigned long seccomp_mode)
>  {
>  	assert_spin_locked(&current->sighand->siglock);
>  
> -	if (current->seccomp.mode && current->seccomp.mode != seccomp_mode)
> -		return false;
> +	if ((current->seccomp.mode == SECCOMP_MODE_STRICT ||
> +	     current->seccomp.mode == SECCOMP_MODE_FILTER) &&
> +	    current->seccomp.mode != seccomp_mode)
> +		return true;

[Severity: Medium]
Is the transition from SECCOMP_MODE_STRICT to SECCOMP_MODE_COMBINED
structurally unreachable?

In strict mode, the __secure_computing_strict() hook runs during syscall
entry and unconditionally kills the process via SIGKILL if it attempts to
execute any syscall other than read, write, _exit, or sigreturn.

Any attempt to invoke prctl or seccomp to install a filter while in
strict mode will result in immediate termination, preventing the upgrade.

> -	return true;
> +	return false;
>  }

[ ... ]

> @@ -1407,6 +1416,9 @@ int __secure_computing(void)
>  		WARN_ON_ONCE(1);
>  		do_exit(SIGKILL);
>  		return -1;
> +	case SECCOMP_MODE_COMBINED:
> +		__secure_computing_strict(this_syscall);
> +		return __seccomp_filter(this_syscall, false);

[Severity: High]
Could this sequence allow a ptracer to completely bypass strict mode
restrictions via system call manipulation?

If the original system call is permitted by the strict check (for example,
read), __secure_computing_strict() passes and __seccomp_filter()
evaluates the BPF filter.

If the filter returns SECCOMP_RET_TRACE, a ptracer is notified and can use
PTRACE_SETREGS to modify the system call number (for example, changing it
to execve).

While __seccomp_filter() correctly re-evaluates the newly injected syscall
against the BPF filter, __secure_computing_strict() is never re-run. If
the filter permits the new syscall, it will execute, allowing the ptracer to
completely bypass the strict mode sandbox.

>  	default:
>  		BUG();
>  	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260526-seccomp-combined-v1-0-304b1cc3ad24@hill-daniel.co.uk?part=1

  reply	other threads:[~2026-05-26 16:23 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-26 15:32 [PATCH RESEND 0/2] seccomp: Allow using `SECCOMP_MODE_STRICT` with `SECCOMP_MODE_FILTER` Jamie Hill-Daniel
2026-05-26 15:32 ` [PATCH RESEND 1/2] " Jamie Hill-Daniel
2026-05-26 16:23   ` sashiko-bot [this message]
2026-06-12 19:25   ` Will Drewry
2026-06-12 21:24     ` Andy Lutomirski
2026-06-12 22:01       ` clubby789
2026-06-12 22:37         ` Andy Lutomirski
2026-06-12 22:58           ` clubby789
2026-06-12 22:37     ` clubby789
2026-06-12 22:50       ` Andy Lutomirski
2026-05-26 15:32 ` [PATCH RESEND 2/2] selftest: seccomp: Adjust test for using both `STRICT` and `FILTER` Jamie Hill-Daniel
2026-05-26 16:44   ` sashiko-bot
2026-06-13  4:14 ` [PATCH RESEND 0/2] seccomp: Allow using `SECCOMP_MODE_STRICT` with `SECCOMP_MODE_FILTER` Kees Cook
2026-06-15 16:23   ` Jamie Hill-Daniel
2026-06-15 22:38     ` Kees Cook
2026-06-15 23:16       ` Kees Cook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260526162312.44C1F1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=clubby789@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox