From: Alexei Starovoitov Date: Tue, 4 Dec 2018 06:46:04 +0000 (-0800) Subject: bpf: check pending signals while verifying programs X-Git-Tag: rel_imx_4.19.35_1.1.0~7701 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=6ffd9f25c0e957ade0afb0a437cfc08cd31deffc;p=linux.git bpf: check pending signals while verifying programs [ Upstream commit c3494801cd1785e2c25f1a5735fa19ddcf9665da ] 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 Signed-off-by: Alexei Starovoitov Acked-by: Daniel Borkmann Acked-by: Edward Cree Signed-off-by: Daniel Borkmann Signed-off-by: Sasha Levin --- diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 56acfbb80104..2954e4b3abd5 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -4792,6 +4792,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();