From patchwork Thu Nov 23 01:00:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 840633 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="J+bXosUz"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yj1H049RKz9t16 for ; Thu, 23 Nov 2017 12:01:16 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751807AbdKWBBK (ORCPT ); Wed, 22 Nov 2017 20:01:10 -0500 Received: from mail-pl0-f67.google.com ([209.85.160.67]:39729 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751549AbdKWBBJ (ORCPT ); Wed, 22 Nov 2017 20:01:09 -0500 Received: by mail-pl0-f67.google.com with SMTP id l16so1730400pli.6 for ; Wed, 22 Nov 2017 17:01:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=Qfdlr1/PqgUll+HRylobzG4Oa3kUILRKXyKC6Dzq6ao=; b=J+bXosUzzEMQ4kyCM/X3WS5qzbo2TKUVMRnuAH9d5WKv5sxPwZOQGFsYcEVd9jeYWv zMTDyXvZIjfuO1awC5Ed8VW7Y86RARQqLeCwgTD5evxYPmVDwDXQllcuyw0Na1sgtmdx 1pUZyiTH8Q2seh+jp+Baw23afU6XOl7vYj6hZBMvcOUFA46kXjZ+VXSvOibqWKKzhxEg BqznNWGVy72yH3ubN5Xjmbpy85UrMX20zNXxDYE+UHMLfSKsupYZ1KvLOMvxdL8JIaBz BCoAwawx7DC7ftSQEDuGZj+ZATraiGSi1COqYXHQxxamu6iCkfTJdhgknODFRY58vfV6 eS+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Qfdlr1/PqgUll+HRylobzG4Oa3kUILRKXyKC6Dzq6ao=; b=l/mKHCq8mG0JLDIdK02INmj98VeVL1XWW/3RbkvuxHgJZcCPs/BRZMu6zYNWJJGUWu MhlLetW/NihrTpAtoe+tOzyzwaBUwZrS1MryF34l0vKoHB8noRWiO7OhHNQBaSKq/csj K9PMF+XUKKH3SGlcCt1bApd6t8HZSc7/RqZNSFQIZsJhQLQ0sfpwY3u7uIqUqca35mfv yEhRdzkEyCZKUJpOR3lWnJoF168sXcqzv4QLAcl7kjU2J2o53p7M0UoOLWvDTUIJnB6m Qvi+9pb0gpCCnqvQLmKmaLuak0w/5vjPjqI4QrKTowTm2PisHwpJejwi0Re4gcaQCSEu 4Stw== X-Gm-Message-State: AJaThX6txRxpxR4hVHV1mTgJzncuDDfbki6uv5UjFZgTY8v+AkJjCk3G 8Tvex+vU6Iu2DEwWGYcnyt25VK/P X-Google-Smtp-Source: AGs4zMZX6W0WwVmy4yyQjAVNdPk13/+VG2eisNdYxnkSgdqQSwGSwyWbH//1tVFx+JCW8BeI2dtS2w== X-Received: by 10.84.128.68 with SMTP id 62mr23160111pla.442.1511398868721; Wed, 22 Nov 2017 17:01:08 -0800 (PST) Received: from jkicinski-Precision-T1700.netronome.com ([75.53.12.129]) by smtp.gmail.com with ESMTPSA id f79sm3389348pfd.45.2017.11.22.17.01.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Nov 2017 17:01:08 -0800 (PST) From: Jakub Kicinski To: netdev@vger.kernel.org Cc: oss-drivers@netronome.com, daniel@iogearbox.net, Jakub Kicinski Subject: [PATCH iproute2/master] bpf: initialize the verifier log Date: Wed, 22 Nov 2017 17:00:53 -0800 Message-Id: <20171123010053.2398-1-jakub.kicinski@netronome.com> X-Mailer: git-send-email 2.14.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 Reviewed-by: Quentin Monnet Acked-by: Daniel Borkmann --- 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;