Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3237423imu; Sat, 24 Nov 2018 00:47:42 -0800 (PST) X-Google-Smtp-Source: AJdET5cV99FKhzG0uCU3d1yr9zPUlmel3yIPTJTKMlZdYKQcDDJaOrAEV5M4wX1ix17Q8ibFwSmF X-Received: by 2002:a62:1212:: with SMTP id a18mr20030726pfj.217.1543049262739; Sat, 24 Nov 2018 00:47:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543049262; cv=none; d=google.com; s=arc-20160816; b=PsJgmxqWp64g1ewkgRvSUBE5b/mIvETJcu2Uitm1wb8zmlkD5y8dgE0Gb7BECWpIYj q/Ae+l/RPO+lyEQs04O8lXevsOro9ilzQbcVva6TlpNlG88To3O6k93GwqEGSBF1+Euc 3LiD6/Xc9m2moMGcgQNTJUC9IdNE6Dy2XM8hxsDbyIMmolLbr6BxaivmNVVrDRRRWsUd mq7QsNMMBqtUFYTgjVFbcPCHQqvYE7auFuPLjCSF/ev0F5XDwWz34k+jRFUM0MGy54R/ NxA4QiHhQCvl7I5QUUC3M6cYVqHi7C6T/AUWHdAtNAN7EdSOI3wqcxihzjWNDYa82FvP zTxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=855k05FS5GB9rHz1uOFsGGNM3e8j/g31JE93ZpqrWc0=; b=ORGtBZFrDh+rgOewNSpV+mfP7KNghpXG6wPX1mUMgVlkzIONhIbmASAqIgvdYzc/2u t/f6a1fej0V6I1AKfzLZqyZGF6UcvaDSNeFxyfawLWmbu+E/xjyKEh79FVWmtPAhlAXj yzuebdba8IlPDJARwnYW6MfNsNFOQVzmF6WpqKtd6Q+7rShAPj8L8kya7K1WOg1qiPk7 KYuInSUe5+3a+0S6Aeijig1mVyFw7qcx4r4I3Wm/Nvp2fN354M3wMr33xbuiLn9kYGWQ 9DjC/+43dBRw5XVJf8NFYgYmjwJa7fep41A9QKwRJXLg74s5TCOvQvOeleC7ZrjjaGoc 6ytA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m68-v6si24640752pfm.78.2018.11.24.00.47.28; Sat, 24 Nov 2018 00:47:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395369AbeKXFUZ (ORCPT + 99 others); Sat, 24 Nov 2018 00:20:25 -0500 Received: from imap1.codethink.co.uk ([176.9.8.82]:60741 "EHLO imap1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730102AbeKXFUZ (ORCPT ); Sat, 24 Nov 2018 00:20:25 -0500 Received: from cpc118554-reig6-2-0-cust775.6-3.cable.virginm.net ([86.18.95.8] helo=xylophone.i.decadent.org.uk) by imap1.codethink.co.uk with esmtpsa (Exim 4.84_2 #1 (Debian)) id 1gQGI5-0001K6-0V; Fri, 23 Nov 2018 18:34:57 +0000 Date: Fri, 23 Nov 2018 18:34:55 +0000 From: Ben Hutchings To: Alexei Starovoitov , Daniel Borkmann Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] bpf/verifier: Log instruction patching when verbose logging is enabled Message-ID: <20181123183455.qjokyt6zpa2yck6s@xylophone.i.decadent.org.uk> References: <20181123183356.5q4bu47zpj5wdufb@xylophone.i.decadent.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181123183356.5q4bu47zpj5wdufb@xylophone.i.decadent.org.uk> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org User-space does not have access to the patched eBPF code, but we need to be able to test that patches are being applied. Therefore log distinct messages for each case that requires patching. Signed-off-by: Ben Hutchings --- kernel/bpf/verifier.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 4ce049cd30a3..ea4bc796e545 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -5844,6 +5844,7 @@ static int convert_ctx_accesses(struct bpf_verifier_env *env) verbose(env, "bpf verifier is misconfigured\n"); return -EINVAL; } else if (cnt) { + verbose(env, "patching in prologue\n"); new_prog = bpf_patch_insn_data(env, 0, insn_buf, cnt); if (!new_prog) return -ENOMEM; @@ -5892,6 +5893,9 @@ static int convert_ctx_accesses(struct bpf_verifier_env *env) }; cnt = ARRAY_SIZE(patch); + verbose(env, + "patching in sanitization against SSB at %d\n", + i + delta); new_prog = bpf_patch_insn_data(env, i + delta, patch, cnt); if (!new_prog) return -ENOMEM; @@ -5973,6 +5977,7 @@ static int convert_ctx_accesses(struct bpf_verifier_env *env) } } + verbose(env, "patching explicit ctx access at %d\n", i + delta); new_prog = bpf_patch_insn_data(env, i + delta, insn_buf, cnt); if (!new_prog) return -ENOMEM; @@ -6225,6 +6230,8 @@ static int fixup_bpf_calls(struct bpf_verifier_env *env) cnt = ARRAY_SIZE(mask_and_mod) - (is64 ? 1 : 0); } + verbose(env, "patching in divide-by-zero check at %d\n", + i + delta); new_prog = bpf_patch_insn_data(env, i + delta, patchlet, cnt); if (!new_prog) return -ENOMEM; @@ -6244,6 +6251,8 @@ static int fixup_bpf_calls(struct bpf_verifier_env *env) return -EINVAL; } + verbose(env, "patching implicit ctx access at %d\n", + i + delta); new_prog = bpf_patch_insn_data(env, i + delta, insn_buf, cnt); if (!new_prog) return -ENOMEM; @@ -6307,6 +6316,8 @@ static int fixup_bpf_calls(struct bpf_verifier_env *env) map)->index_mask); insn_buf[2] = *insn; cnt = 3; + verbose(env, "patching in tail-call bounds check at %d", + i + delta); new_prog = bpf_patch_insn_data(env, i + delta, insn_buf, cnt); if (!new_prog) return -ENOMEM; @@ -6342,6 +6353,8 @@ static int fixup_bpf_calls(struct bpf_verifier_env *env) return -EINVAL; } + verbose(env, "patching in map lookup at %d", + i + delta); new_prog = bpf_patch_insn_data(env, i + delta, insn_buf, cnt); if (!new_prog) -- Ben Hutchings, Software Developer Codethink Ltd https://www.codethink.co.uk/ Dale House, 35 Dale Street Manchester, M1 2HF, United Kingdom