Re: [PATCH] seccomp: allow BPF_MOD ALU instructions
From: Kees Cook
Date: Mon Mar 16 2020 - 17:24:03 EST
On Mon, Mar 16, 2020 at 04:36:46PM +0000, Anton Protopopov wrote:
> The BPF_MOD ALU instructions could be utilized by seccomp classic BPF filters,
> but were missing from the explicit list of allowed calls since its introduction
> in the original e2cfabdfd075 ("seccomp: add system call filtering using BPF")
> commit. Add support for these instructions by adding them to the allowed list
> in the seccomp_check_filter function.
>
> Signed-off-by: Anton Protopopov <a.s.protopopov@xxxxxxxxx>
This has been suggested in the past, but was deemed ultimately redundant:
https://lore.kernel.org/lkml/201908121035.06695C79F@keescook/
Is there a strong reason it's needed?
Thanks!
-Kees
> ---
> kernel/seccomp.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/kernel/seccomp.c b/kernel/seccomp.c
> index b6ea3dcb57bf..cae7561b44d4 100644
> --- a/kernel/seccomp.c
> +++ b/kernel/seccomp.c
> @@ -206,6 +206,8 @@ static int seccomp_check_filter(struct sock_filter *filter, unsigned int flen)
> case BPF_ALU | BPF_MUL | BPF_X:
> case BPF_ALU | BPF_DIV | BPF_K:
> case BPF_ALU | BPF_DIV | BPF_X:
> + case BPF_ALU | BPF_MOD | BPF_K:
> + case BPF_ALU | BPF_MOD | BPF_X:
> case BPF_ALU | BPF_AND | BPF_K:
> case BPF_ALU | BPF_AND | BPF_X:
> case BPF_ALU | BPF_OR | BPF_K:
> --
> 2.19.1
--
Kees Cook