linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] seccomp: allow BPF_MOD ALU instructions
@ 2020-03-16 16:36 Anton Protopopov
  2020-03-16 21:23 ` Kees Cook
  0 siblings, 1 reply; 10+ messages in thread
From: Anton Protopopov @ 2020-03-16 16:36 UTC (permalink / raw)
  To: Kees Cook, Andy Lutomirski, Will Drewry, linux-kernel
  Cc: Anton Protopopov, Daniel Borkmann, bpf

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@gmail.com>
---
 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

^ permalink raw reply related	[flat|nested] 10+ messages in thread
* [PATCH] seccomp: allow BPF_MOD ALU instructions
@ 2019-08-09 18:26 Paul Chaignon
  2019-08-11  8:58 ` Paul Chaignon
  0 siblings, 1 reply; 10+ messages in thread
From: Paul Chaignon @ 2019-08-09 18:26 UTC (permalink / raw)
  To: Kees Cook; +Cc: Andy Lutomirski, Will Drewry, linux-kernel

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.

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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-03-18 15:23 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-16 16:36 [PATCH] seccomp: allow BPF_MOD ALU instructions 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
  -- strict thread matches above, loose matches on Subject: below --
2019-08-09 18:26 Paul Chaignon
2019-08-11  8:58 ` Paul Chaignon
2019-08-12 17:38   ` Kees Cook

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).