netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: netdev@vger.kernel.org
Cc: oss-drivers@netronome.com, daniel@iogearbox.net,
	Jakub Kicinski <jakub.kicinski@netronome.com>
Subject: [PATCH iproute2/master] bpf: initialize the verifier log
Date: Wed, 22 Nov 2017 17:00:53 -0800	[thread overview]
Message-ID: <20171123010053.2398-1-jakub.kicinski@netronome.com> (raw)

If program loading fails before verifier prints its first
message, the verifier log will not be initialized.  Always
set the first character of the log buffer to zero to make
sure we don't dump non-printable characters to the terminal.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
---
 lib/bpf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/bpf.c b/lib/bpf.c
index 10ea23a471ef..fdc28772fb71 100644
--- a/lib/bpf.c
+++ b/lib/bpf.c
@@ -1153,7 +1153,7 @@ static int bpf_log_realloc(struct bpf_elf_ctx *ctx)
 {
 	const size_t log_max = UINT_MAX >> 8;
 	size_t log_size = ctx->log_size;
-	void *ptr;
+	char *ptr;
 
 	if (!ctx->log) {
 		log_size = 65536;
@@ -1169,6 +1169,7 @@ static int bpf_log_realloc(struct bpf_elf_ctx *ctx)
 	if (!ptr)
 		return -ENOMEM;
 
+	ptr[0] = 0;
 	ctx->log = ptr;
 	ctx->log_size = log_size;
 
-- 
2.14.1

             reply	other threads:[~2017-11-23  1:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-23  1:00 Jakub Kicinski [this message]
2017-11-23  9:31 ` [PATCH iproute2/master] bpf: initialize the verifier log Daniel Borkmann
2017-11-24  4:48 ` Stephen Hemminger

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=20171123010053.2398-1-jakub.kicinski@netronome.com \
    --to=jakub.kicinski@netronome.com \
    --cc=daniel@iogearbox.net \
    --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).