netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexei Starovoitov <ast@kernel.org>
To: "David S . Miller" <davem@davemloft.net>
Cc: <daniel@iogearbox.net>, <ecree@solarflare.com>,
	<anatoly.trosinenko@gmail.com>, <netdev@vger.kernel.org>,
	<kernel-team@fb.com>
Subject: [PATCH bpf 1/3] bpf: check pending signals while verifying programs
Date: Mon, 3 Dec 2018 22:46:04 -0800	[thread overview]
Message-ID: <20181204064606.803625-2-ast@kernel.org> (raw)
In-Reply-To: <20181204064606.803625-1-ast@kernel.org>

Malicious user space may try to force the verifier to use as much cpu
time and memory as possible. Hence check for pending signals
while verifying the program.
Note that suspend of sys_bpf(PROG_LOAD) syscall will lead to EAGAIN,
since the kernel has to release the resources used for program verification.

Reported-by: Anatoly Trosinenko <anatoly.trosinenko@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Edward Cree <ecree@solarflare.com>
---
 kernel/bpf/verifier.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 6dd419550aba..751bb30b7c5c 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -5148,6 +5148,9 @@ static int do_check(struct bpf_verifier_env *env)
 			goto process_bpf_exit;
 		}
 
+		if (signal_pending(current))
+			return -EAGAIN;
+
 		if (need_resched())
 			cond_resched();
 
-- 
2.17.1

  reply	other threads:[~2018-12-04  6:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-04  6:46 [PATCH bpf 0/3] bpf: improve verifier resilience Alexei Starovoitov
2018-12-04  6:46 ` Alexei Starovoitov [this message]
2018-12-04  6:46 ` [PATCH bpf 2/3] bpf: improve verifier branch analysis Alexei Starovoitov
2018-12-04  6:46 ` [PATCH bpf 3/3] bpf: add per-insn complexity limit Alexei Starovoitov
2018-12-04 16:23 ` [PATCH bpf 0/3] bpf: improve verifier resilience Daniel Borkmann

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=20181204064606.803625-2-ast@kernel.org \
    --to=ast@kernel.org \
    --cc=anatoly.trosinenko@gmail.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=ecree@solarflare.com \
    --cc=kernel-team@fb.com \
    --cc=netdev@vger.kernel.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).