From: Quentin Monnet <quentin.monnet@netronome.com>
To: daniel@iogearbox.net, alexei.starovoitov@gmail.com,
netdev@vger.kernel.org
Cc: oss-drivers@netronome.com, jakub.kicinski@netronome.com
Subject: [PATCH bpf-next v2 13/14] bpf: export function to write into verifier log buffer
Date: Wed, 10 Jan 2018 12:26:06 +0000 [thread overview]
Message-ID: <1515587167-1959-14-git-send-email-quentin.monnet@netronome.com> (raw)
In-Reply-To: <1515587167-1959-1-git-send-email-quentin.monnet@netronome.com>
Rename the BPF verifier `verbose()` to `bpf_verifier_log_write()` and
export it, so that other components (in particular, drivers for BPF
offload) can reuse the user buffer log to dump error messages at
verification time.
Renaming `verbose()` was necessary in order to avoid a name so generic
to be exported to the global namespace. However to prevent too much pain
for backports, the calls to `verbose()` in the kernel BPF verifier were
not changed. Instead, use function aliasing to make `verbose` point to
`bpf_verifier_log_write`. Another solution could consist in making a
wrapper around `verbose()`, but since it is a variadic function, I don't
see a clean way without creating two identical wrappers, one for the
verifier and one to export.
Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
v2: Replace #define by function aliasing for verbose (thanks Daniel).
---
include/linux/bpf_verifier.h | 3 +++
kernel/bpf/verifier.c | 16 ++++++++++++----
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h
index 2feb218c001d..6b66cd1aa0b9 100644
--- a/include/linux/bpf_verifier.h
+++ b/include/linux/bpf_verifier.h
@@ -192,6 +192,9 @@ struct bpf_verifier_env {
u32 subprog_cnt;
};
+__printf(2, 3) void bpf_verifier_log_write(struct bpf_verifier_env *env,
+ const char *fmt, ...);
+
static inline struct bpf_reg_state *cur_regs(struct bpf_verifier_env *env)
{
struct bpf_verifier_state *cur = env->cur_state;
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index a2b211262c25..3690e292d4ce 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -169,11 +169,11 @@ struct bpf_call_arg_meta {
static DEFINE_MUTEX(bpf_verifier_lock);
/* log_level controls verbosity level of eBPF verifier.
- * verbose() is used to dump the verification trace to the log, so the user
- * can figure out what's wrong with the program
+ * bpf_verifier_log_write() is used to dump the verification trace to the log,
+ * so the user can figure out what's wrong with the program
*/
-static __printf(2, 3) void verbose(struct bpf_verifier_env *env,
- const char *fmt, ...)
+__printf(2, 3) void bpf_verifier_log_write(struct bpf_verifier_env *env,
+ const char *fmt, ...)
{
struct bpf_verifer_log *log = &env->log;
unsigned int n;
@@ -197,6 +197,14 @@ static __printf(2, 3) void verbose(struct bpf_verifier_env *env,
else
log->ubuf = NULL;
}
+EXPORT_SYMBOL_GPL(bpf_verifier_log_write);
+/* Historically bpf_verifier_log_write was called verbose, but the name was too
+ * generic for symbol export. The function was renamed, but not the calls in
+ * the verifier to avoid complicating backports. Hence the alias below.
+ */
+static __printf(2, 3) void verbose(struct bpf_verifier_env *env,
+ const char *fmt, ...)
+ __attribute__((alias("bpf_verifier_log_write")));
static bool type_is_pkt_pointer(enum bpf_reg_type type)
{
--
2.7.4
next prev parent reply other threads:[~2018-01-10 12:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-10 12:25 [PATCH bpf-next v2 00/14] nfp: bpf: relocations, verifier log, signed jumps and other updates Quentin Monnet
2018-01-10 12:25 ` [PATCH bpf-next v2 01/14] nfp: don't try to register XDP rxq structures on control queues Quentin Monnet
2018-01-10 12:25 ` [PATCH bpf-next v2 02/14] nfp: fix incumbent kdoc warnings Quentin Monnet
2018-01-10 12:25 ` [PATCH bpf-next v2 03/14] nfp: bpf: round up the size of the stack Quentin Monnet
2018-01-10 12:25 ` [PATCH bpf-next v2 04/14] nfp: bpf: don't allow changing MTU above BPF offload limit when active Quentin Monnet
2018-01-10 12:25 ` [PATCH bpf-next v2 05/14] nfp: bpf: allow disabling TC offloads when XDP active Quentin Monnet
2018-01-10 12:25 ` [PATCH bpf-next v2 06/14] nfp: bpf: move jump resolution to jit.c Quentin Monnet
2018-01-10 12:26 ` [PATCH bpf-next v2 07/14] nfp: bpf: add helpers for modifying branch addresses Quentin Monnet
2018-01-10 12:26 ` [PATCH bpf-next v2 08/14] nfp: bpf: relocate jump targets just before the load Quentin Monnet
2018-01-10 12:26 ` [PATCH bpf-next v2 09/14] nfp: bpf: don't depend on high order allocations for program image Quentin Monnet
2018-01-10 12:26 ` [PATCH bpf-next v2 10/14] nfp: bpf: use a large constant in unresolved branches Quentin Monnet
2018-01-10 12:26 ` [PATCH bpf-next v2 11/14] nfp: hand over to BPF offload app at coarser granularity Quentin Monnet
2018-01-10 12:26 ` [PATCH bpf-next v2 12/14] nfp: bpf: add signed jump insns Quentin Monnet
2018-01-10 12:26 ` Quentin Monnet [this message]
2018-01-10 12:26 ` [PATCH bpf-next v2 14/14] nfp: bpf: reuse verifier log for debug messages Quentin Monnet
2018-01-10 14:05 ` [PATCH bpf-next v2 00/14] nfp: bpf: relocations, verifier log, signed jumps and other updates 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=1515587167-1959-14-git-send-email-quentin.monnet@netronome.com \
--to=quentin.monnet@netronome.com \
--cc=alexei.starovoitov@gmail.com \
--cc=daniel@iogearbox.net \
--cc=jakub.kicinski@netronome.com \
--cc=netdev@vger.kernel.org \
--cc=oss-drivers@netronome.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).