From: Christy Lee <christylee@fb.com>
To: <ast@kernel.org>, <daniel@iogearbox.net>, <andrii@kernel.org>
Cc: <bpf@vger.kernel.org>, <kernel-team@fb.com>, <christylee@fb.com>,
<christyc.y.lee@gmail.com>
Subject: [PATCH v2 bpf-next 0/3] Improve verifier log readability
Date: Wed, 15 Dec 2021 11:22:22 -0800 [thread overview]
Message-ID: <20211215192225.1278237-1-christylee@fb.com> (raw)
Simplify verifier logs and improve readability.
Changelog:
----------
v1 -> v2:
v1: https://lore.kernel.org/bpf/20211213182117.682461-1-christylee@fb.com/
Patch 2/3:
* Verifier will skip insn_idx when the insn is longer than 8 bytes,
example:
0000000000000000 <good_prog>:
0: 18 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 r2 = 0 ll
2: 63 12 00 00 00 00 00 00 *(u32 *)(r2 + 0) = r1
3: 61 20 04 00 00 00 00 00 r0 = *(u32 *)(r2 + 4)
4: 95 00 00 00 00 00 00 00 exit
It's incorrect to check that prev_insn_idx = insn_idx - 1, skip this
check and print the verifier state on the correct line.
Before:
0: R1=ctx(id=0,off=0,imm=0) R10=fp0
; a[0] = (int)(long)ctx;
0: (18) r2 = 0xffffc900006de000
2: R2_w=map_value(id=0,off=0,ks=4,vs=16,imm=0)
2: (63) *(u32 *)(r2 +0) = r1
After:
0: R1=ctx(id=0,off=0,imm=0) R10=fp0
; a[0] = (int)(long)ctx;
0: (18) r2 = 0xffffc900006de000 ; R2_w=map_value(id=0,off=0,ks=4,vs=16,imm=0)
2: (63) *(u32 *)(r2 +0) = r1
* Track previous line logging length in env, allow aligning intsruction
from anywhere in the verifier
* Fixed bug where the verifier printed verifier state after checking
source memory access but before check destination memory access,
this ensures the aligned verifier state contains all scratched
registers
Patch 3/3:
* Added one more case where we should only log in log_level=2
Christy Lee (3):
Only print scratched registers and stack slots to verifier logs
Right align verifier states in verifier logs
Only output backtracking information in log level 2
include/linux/bpf_verifier.h | 10 +
kernel/bpf/verifier.c | 131 +++++++++--
.../testing/selftests/bpf/prog_tests/align.c | 214 +++++++++---------
3 files changed, 232 insertions(+), 123 deletions(-)
--
2.30.2
next reply other threads:[~2021-12-15 19:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-15 19:22 Christy Lee [this message]
2021-12-15 19:22 ` [PATCH v2 bpf-next 1/3] Only print scratched registers and stack slots to verifier logs Christy Lee
2021-12-16 7:02 ` Andrii Nakryiko
[not found] ` <CAPqJDZpuZ586TawooQhxZGvOqgF4yCjT0yOLEXAUer8eJDO7gw@mail.gmail.com>
2021-12-16 16:02 ` Christy Lee
2021-12-15 19:22 ` [PATCH v2 bpf-next 2/3] Right align verifier states in " Christy Lee
2021-12-16 7:02 ` Andrii Nakryiko
[not found] ` <CAPqJDZr1AudE2PfbZQarHf0N5i_-xm-zyhfLqS5rogX98UtNLQ@mail.gmail.com>
2021-12-16 16:03 ` Christy Lee
2021-12-16 19:37 ` Andrii Nakryiko
2021-12-15 19:22 ` [PATCH v2 bpf-next 3/3] Only output backtracking information in log level 2 Christy Lee
2021-12-16 7:02 ` Andrii Nakryiko
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=20211215192225.1278237-1-christylee@fb.com \
--to=christylee@fb.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=christyc.y.lee@gmail.com \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
/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).