linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Chaignon <paul.chaignon@gmail.com>
To: Kees Cook <keescook@chromium.org>
Cc: Andy Lutomirski <luto@amacapital.net>,
	Will Drewry <wad@chromium.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] seccomp: allow BPF_MOD ALU instructions
Date: Sun, 11 Aug 2019 10:58:33 +0200	[thread overview]
Message-ID: <CAO5pjwSe+U70tSPjKOgFsqqF=gCKXPDREzYF81NCZ03kGAyWww@mail.gmail.com> (raw)
In-Reply-To: <20190809182621.GA4074@Nover>

On Fri, Aug 9, 2019 at 8:26 PM Paul Chaignon <paul.chaignon@orange.com> wrote:
>
> We need BPF_MOD to match system calls against whitelists encoded as 32-bit
> bit arrays.  The selection of the syscall's bit in the appropriate bit
> array requires a modulo operation such that X = 1 << nr % 32.

Of course, X = 1 << nr & 0x1F, and we can do without BPF_MOD in our case.
I'll put that on a lack of sleep...

>
> Signed-off-by: Paul Chaignon <paul.chaignon@orange.com>
> ---
>  kernel/seccomp.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/kernel/seccomp.c b/kernel/seccomp.c
> index 811b4a86cdf6..87de6532ff6d 100644
> --- a/kernel/seccomp.c
> +++ b/kernel/seccomp.c
> @@ -205,6 +205,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.17.1

  reply	other threads:[~2019-08-11  8:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-09 18:26 [PATCH] seccomp: allow BPF_MOD ALU instructions Paul Chaignon
2019-08-11  8:58 ` Paul Chaignon [this message]
2019-08-12 17:38   ` Kees Cook
2020-03-16 16:36 Anton Protopopov
2020-03-16 21:23 ` Kees Cook
2020-03-16 22:17   ` Anton Protopopov
2020-03-17 20:20     ` Kees Cook
2020-03-18  1:11       ` Anton Protopopov
2020-03-18  4:06         ` Kees Cook
2020-03-18 15:23           ` Anton Protopopov

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='CAO5pjwSe+U70tSPjKOgFsqqF=gCKXPDREzYF81NCZ03kGAyWww@mail.gmail.com' \
    --to=paul.chaignon@gmail.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=wad@chromium.org \
    /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;
as well as URLs for NNTP newsgroup(s).