Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1022013yba; Thu, 4 Apr 2019 02:37:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqyv124U057k8typAdVPGF/aqdN5n1EdJJ8hlHKiI0nwuK2ZWWhqDeGCDV4CM6kP1q7NgeSm X-Received: by 2002:a17:902:54f:: with SMTP id 73mr5219615plf.210.1554370652491; Thu, 04 Apr 2019 02:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554370652; cv=none; d=google.com; s=arc-20160816; b=iDX/frTg4sspMwF+U6K/IkYyZkjgQUFgXo3xhfHGzMs7s/xw7M7DP3ZnU5giKxL+md 5+8wa3wRbln05Ql8SkAQQZxyl5tgF++CfxZfoBAKGgqLRlkuUw8bwvC5EPQY2E62B3Qh TvpsmTEumiOwrbz2E+v4sVXfLHWNDOHKgZM0z/tt9UF3cEiB8vuTjxcb+oVW1urRZWFK OSbYaZn++Ezc67/XP8LuvFDJBGudmXtOyBFuyKchWhV8w1qFfr7AQmT98fH9R19cmlZq TCajDy/dE0tzGi4dFY+jdBiyxI+9WBoANr8CHiO21yZaEwpcHKpmGyHNHoLhs1EO3IX9 TpAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oESCwMB567MMbwhbsSpiTd+nYuz2n/pHumnaIlavm04=; b=tbjmMLOCEdTSdIWs6///8H1OPPetmZbw4Bu979+PFAzVBN1LqEquf+kiR4DgJejq6w A+K6Xg1P/vShFKLOh6I1PufQkhHwzb3E/OC1J+bTGohsBO9JgL0B7sIixO3uD8ww3y4D FbcFZ6r5IOLvrsU6vh7hTLNH2PK8wAz40I0zyW73pTk7YnLPmziiCO6IFvrhC1DdQXnK 2NX/lw+c1V4+UfoYQ59TAx/UZpEML/Q4R+I+1dXdk7qUKkIQWt+YdWgKzfaWBb0V+gUU m1nrffaaFsPamTBNgC6x5dtGIhQ24M5C/CMqXUSNDnl1/puuuroqWs+qP+Ne449jN1vr jWjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=01XfR1ky; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 140si15919144pga.460.2019.04.04.02.37.17; Thu, 04 Apr 2019 02:37:32 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=01XfR1ky; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732592AbfDDJfz (ORCPT + 99 others); Thu, 4 Apr 2019 05:35:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:44374 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732235AbfDDJGC (ORCPT ); Thu, 4 Apr 2019 05:06:02 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 00D072177E; Thu, 4 Apr 2019 09:06:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368761; bh=TOqehOE+RvjY+baOPNqUbSCNiWva0ZSLbPoTo/BWFWA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=01XfR1kymoBq9aAyvSN4Cha1GWz1Kh6m24NlUx7LkE32h7a/KLH2FCP/WzU6B4iF0 jdrVHSabVYJUTtgT3DsDAIh0QURkHmVzMsVJjPIJKwIJT+ExruP0l+qAFOtVy8hCzm klBiPTsjkdDJGH/b7WtwlH1V4MuzH7NikbIZrEAk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stanislav Fomichev , Daniel Borkmann , Sasha Levin Subject: [PATCH 4.19 144/187] selftests/bpf: skip verifier tests for unsupported program types Date: Thu, 4 Apr 2019 10:48:01 +0200 Message-Id: <20190404084609.946908305@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 8184d44c9a577a2f1842ed6cc844bfd4a9981d8e ] Use recently introduced bpf_probe_prog_type() to skip tests in the test_verifier() if bpf_verify_program() fails. The skipped test is indicated in the output. Example: ... 679/p bpf_get_stack return R0 within range SKIP (unsupported program type 5) 680/p ld_abs: invalid op 1 OK ... Summary: 863 PASSED, 165 SKIPPED, 3 FAILED Signed-off-by: Stanislav Fomichev Signed-off-by: Daniel Borkmann Signed-off-by: Sasha Levin --- tools/testing/selftests/bpf/test_verifier.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c index 9db5a7378f40..294fc18aba2a 100644 --- a/tools/testing/selftests/bpf/test_verifier.c +++ b/tools/testing/selftests/bpf/test_verifier.c @@ -32,6 +32,7 @@ #include #include +#include #ifdef HAVE_GENHDR # include "autoconf.h" @@ -56,6 +57,7 @@ #define UNPRIV_SYSCTL "kernel/unprivileged_bpf_disabled" static bool unpriv_disabled = false; +static int skips; struct bpf_test { const char *descr; @@ -12770,6 +12772,11 @@ static void do_test_single(struct bpf_test *test, bool unpriv, fd_prog = bpf_verify_program(prog_type ? : BPF_PROG_TYPE_SOCKET_FILTER, prog, prog_len, test->flags & F_LOAD_WITH_STRICT_ALIGNMENT, "GPL", 0, bpf_vlog, sizeof(bpf_vlog), 1); + if (fd_prog < 0 && !bpf_probe_prog_type(prog_type, 0)) { + printf("SKIP (unsupported program type %d)\n", prog_type); + skips++; + goto close_fds; + } expected_ret = unpriv && test->result_unpriv != UNDEF ? test->result_unpriv : test->result; @@ -12905,7 +12912,7 @@ static void get_unpriv_disabled() static int do_test(bool unpriv, unsigned int from, unsigned int to) { - int i, passes = 0, errors = 0, skips = 0; + int i, passes = 0, errors = 0; for (i = from; i < to; i++) { struct bpf_test *test = &tests[i]; -- 2.19.1