netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexei Starovoitov <ast@fb.com>
To: "David S . Miller" <davem@davemloft.net>
Cc: Daniel Borkmann <daniel@iogearbox.net>,
	John Fastabend <john.fastabend@gmail.com>,
	<netdev@vger.kernel.org>, <kernel-team@fb.com>
Subject: [PATCH net-next 4/7] bpf: improve verifier liveness marks
Date: Thu, 30 Nov 2017 21:31:38 -0800	[thread overview]
Message-ID: <20171201053141.3992592-5-ast@fb.com> (raw)
In-Reply-To: <20171201053141.3992592-1-ast@fb.com>

registers with pointers filled from stack were missing live_written marks
which caused liveness propagation to unnecessary mark more registers as
live_read and miss state pruning opportunities later on.

                     before  after
bpf_lb-DLB_L3.o       2285   2270
bpf_lb-DLB_L4.o       3723   3682
bpf_lb-DUNKNOWN.o     1110   1110
bpf_lxc-DDROP_ALL.o   27954  27876
bpf_lxc-DUNKNOWN.o    38954  38780
bpf_netdev.o          16943  16937
bpf_overlay.o         7929   7929

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
---
 kernel/bpf/verifier.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 14ad7c6e806a..46ff4e5b3fb7 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -795,6 +795,11 @@ static int check_stack_read(struct bpf_verifier_env *env,
 		if (value_regno >= 0) {
 			/* restore register state from stack */
 			state->regs[value_regno] = state->stack[spi].spilled_ptr;
+			/* mark reg as written since spilled pointer state likely
+			 * has its liveness marks cleared by is_state_visited()
+			 * which resets stack/reg liveness for state transitions
+			 */
+			state->regs[value_regno].live |= REG_LIVE_WRITTEN;
 			mark_stack_slot_read(state, spi);
 		}
 		return 0;
-- 
2.9.5

  parent reply	other threads:[~2017-12-01  5:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-01  5:31 [PATCH net-next 0/7] bpf: verifier improvements and cleanups Alexei Starovoitov
2017-12-01  5:31 ` [PATCH net-next 1/7] bpf: fix stack state printing in verifier log Alexei Starovoitov
2017-12-01  5:31 ` [PATCH net-next 2/7] bpf: print liveness info to " Alexei Starovoitov
2017-12-01  5:31 ` [PATCH net-next 3/7] bpf: don't mark FP reg as uninit Alexei Starovoitov
2017-12-01  5:31 ` Alexei Starovoitov [this message]
2017-12-01  5:31 ` [PATCH net-next 5/7] bpf: improve JEQ/JNE path walking Alexei Starovoitov
2017-12-01  5:31 ` [PATCH net-next 6/7] bpf: cleanup register_is_null() Alexei Starovoitov
2017-12-01  5:31 ` [PATCH net-next 7/7] selftests/bpf: adjust test_align expected output Alexei Starovoitov
2017-12-01 10:28 ` [PATCH net-next 0/7] bpf: verifier improvements and cleanups 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=20171201053141.3992592-5-ast@fb.com \
    --to=ast@fb.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=john.fastabend@gmail.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).