From: Alexei Starovoitov Subject: [PATCH bpf-next 1/4] bpf: speed up stacksafe check Date: Tue, 11 Dec 2018 21:28:51 -0800 Message-ID: <20181212052854.4105971-2-ast@kernel.org> References: <20181212052854.4105971-1-ast@kernel.org> Mime-Version: 1.0 Content-Type: text/plain Cc: , , , , , To: "David S . Miller" Return-path: Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:51800 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726490AbeLLF3A (ORCPT ); Wed, 12 Dec 2018 00:29:00 -0500 Received: from pps.filterd (m0001303.ppops.net [127.0.0.1]) by m0001303.ppops.net (8.16.0.27/8.16.0.27) with SMTP id wBC5M1LJ020835 for ; Tue, 11 Dec 2018 21:29:00 -0800 Received: from mail.thefacebook.com ([199.201.64.23]) by m0001303.ppops.net with ESMTP id 2pav1u00th-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 11 Dec 2018 21:29:00 -0800 In-Reply-To: <20181212052854.4105971-1-ast@kernel.org> Sender: netdev-owner@vger.kernel.org List-ID: don't check the same stack liveness condition 8 times. once is enough. Signed-off-by: Alexei Starovoitov --- kernel/bpf/verifier.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 8b511a4fe84a..d4db4727a50e 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -5147,9 +5147,11 @@ static bool stacksafe(struct bpf_func_state *old, for (i = 0; i < old->allocated_stack; i++) { spi = i / BPF_REG_SIZE; - if (!(old->stack[spi].spilled_ptr.live & REG_LIVE_READ)) + if (!(old->stack[spi].spilled_ptr.live & REG_LIVE_READ)) { + i += BPF_REG_SIZE - 1; /* explored state didn't use this */ continue; + } if (old->stack[spi].slot_type[i % BPF_REG_SIZE] == STACK_INVALID) continue; -- 2.17.1