All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: davem@davemloft.net
Cc: ast@fb.com, john.fastabend@gmail.com, netdev@vger.kernel.org
Subject: [PATCH net-next 5/7] bpf: extend bpf_trace_printk to support %i
Date: Sun,  2 Jul 2017 02:13:29 +0200	[thread overview]
Message-ID: <f60861b7e62e6d0460ba183e6bf600b3c4750777.1498952486.git.daniel@iogearbox.net> (raw)
In-Reply-To: <cover.1498952486.git.daniel@iogearbox.net>
In-Reply-To: <cover.1498952486.git.daniel@iogearbox.net>

From: John Fastabend <john.fastabend@gmail.com>

Currently, bpf_trace_printk does not support common formatting
symbol '%i' however vsprintf does and is what eventually gets
called by bpf helper. If users are used to '%i' and currently
make use of it, then bpf_trace_printk will just return with
error without dumping anything to the trace pipe, so just add
support for '%i' to the helper.

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

diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 5c6d538..3738519 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -122,8 +122,8 @@ static const struct bpf_func_proto *bpf_get_probe_write_proto(void)
 }
 
 /*
- * limited trace_printk()
- * only %d %u %x %ld %lu %lx %lld %llu %llx %p %s conversion specifiers allowed
+ * Only limited trace_printk() conversion specifiers allowed:
+ * %d %i %u %x %ld %li %lu %lx %lld %lli %llu %llx %p %s
  */
 BPF_CALL_5(bpf_trace_printk, char *, fmt, u32, fmt_size, u64, arg1,
 	   u64, arg2, u64, arg3)
@@ -198,7 +198,8 @@ static const struct bpf_func_proto *bpf_get_probe_write_proto(void)
 			i++;
 		}
 
-		if (fmt[i] != 'd' && fmt[i] != 'u' && fmt[i] != 'x')
+		if (fmt[i] != 'i' && fmt[i] != 'd' &&
+		    fmt[i] != 'u' && fmt[i] != 'x')
 			return -EINVAL;
 		fmt_cnt++;
 	}
-- 
1.9.3

  parent reply	other threads:[~2017-07-02  0:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-02  0:13 [PATCH net-next 0/7] Misc BPF helper/verifier improvements Daniel Borkmann
2017-07-02  0:13 ` [PATCH net-next 1/7] bpf, net: add skb_mac_header_len helper Daniel Borkmann
2017-07-02  0:13 ` [PATCH net-next 2/7] bpf: add bpf_skb_adjust_room helper Daniel Borkmann
2017-07-02  0:13 ` [PATCH net-next 3/7] bpf: simplify narrower ctx access Daniel Borkmann
2017-07-02  0:13 ` [PATCH net-next 4/7] bpf: export whether tail call has jited owner Daniel Borkmann
2017-07-02  0:13 ` Daniel Borkmann [this message]
2017-07-02  0:13 ` [PATCH net-next 6/7] bpf, verifier: add additional patterns to evaluate_reg_imm_alu Daniel Borkmann
2017-07-02  0:13 ` [PATCH net-next 7/7] bpf: add various test cases for verifier selftest Daniel Borkmann
2017-07-03  9:23 ` [PATCH net-next 0/7] Misc BPF helper/verifier improvements David Miller

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=f60861b7e62e6d0460ba183e6bf600b3c4750777.1498952486.git.daniel@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=ast@fb.com \
    --cc=davem@davemloft.net \
    --cc=john.fastabend@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.