Subject: Re: [PATCH v2 1/3] seccomp: add SECCOMP_USER_NOTIF_FLAG_CONTINUE

From: Kees Cook <[email-masked]>
Date: Thu, 10 Oct 2019 14:45:38 -0700

On Fri, Sep 20, 2019 at 10:30:05AM +0200, Christian Brauner wrote:
> + * Similar precautions should be applied when stacking SECCOMP_RET_USER_NOTIF.
> + * For SECCOMP_RET_USER_NOTIF filters acting on the same syscall the uppermost
> + * filter takes precedence. This means that the uppermost
> + * SECCOMP_RET_USER_NOTIF filter can override any SECCOMP_IOCTL_NOTIF_SEND from
> + * lower filters essentially allowing all syscalls to pass by using
> + * SECCOMP_USER_NOTIF_FLAG_CONTINUE. Note that SECCOMP_RET_USER_NOTIF can
                                                          ^^^^^^^^^^^^^^
This is meant to read RET_TRACE, yes?

> + * equally be overriden by SECCOMP_USER_NOTIF_FLAG_CONTINUE.

I rewrote this paragraph with that corrected and swapping some
"upper/lower" to "most recently added" etc:

+ * Similar precautions should be applied when stacking SECCOMP_RET_USER_NOTIF
+ * or SECCOMP_RET_TRACE. For SECCOMP_RET_USER_NOTIF filters acting on the
+ * same syscall, the most recently added filter takes precedence. This means
+ * that the new SECCOMP_RET_USER_NOTIF filter can override any
+ * SECCOMP_IOCTL_NOTIF_SEND from earlier filters, essentially allowing all
+ * such filtered syscalls to be executed by sending the response
+ * SECCOMP_USER_NOTIF_FLAG_CONTINUE. Note that SECCOMP_RET_TRACE can equally
+ * be overriden by SECCOMP_USER_NOTIF_FLAG_CONTINUE.

Ultimately, I think this caveat is fine. RET_USER_NOTIF and RET_TRACE are
both used from the "process manager" use-case. The benefits of "continue"
semantics here outweighs the RET_USER_NOTIF and RET_TRACE "bypass". If
we end up in a situation where we need to deal with some kind of
nesting where this is a problem in practice, we can revisit this.

Applied to my for-next/seccomp. Thanks!

-- 
Kees Cook