Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5644623img; Wed, 27 Mar 2019 12:19:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqz3XMJqccbyIVm6o/nh4TL00DNz9jm8ISHIXkmDb/LxrOyhkoOZX2UVjy+i2VG/0hAJU4pe X-Received: by 2002:aa7:9151:: with SMTP id 17mr1795921pfi.192.1553714385763; Wed, 27 Mar 2019 12:19:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553714385; cv=none; d=google.com; s=arc-20160816; b=B/UCesD7+41a/5N1g4DbJ5uxseJgChJrrpY93CLvXH/VZlvVjibVonIgUjAgDUEZzX mpWtiLEhf4OEGaUI+YAbIf8ZnqP2bbaUmDB2JyE+4pPjK0+NKrnIaCGaQK45Antgah2J CjGrpNeL4gH1m5siyCx6Xj/lAUVxrsG1Ly9X0Nk9PRyiP8n3n2b73YVx0OC78S9iONAZ 0D8mWar7fA5inuO3OGV2rLg5YVJ6mCsrhw8q8ov9bRAlh8lfX7pkWrXX+iVnkl7gCyUJ y0pyvhC7UA7AZVFr+SIqJ0/8bgSVtmZtpKFjOP324POv9zrR5n8YkaXbhbLg6B9baBHr Gddg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hGnkcQPeasQuhaLkY78tdVvSumQU+P7nGjDFqsacZxA=; b=fo50eAExg7Nc55v/qt1chUSp4cnYfGaGMdnWmmebky3aJI/csR4MnutWXOwefwp0Y1 /ybLXQHWjQQjBh+bySKbnHVTwzJ1XxD9RrIsH0EttfsIjHyaDV9CUs3XwnNlmwyLMLp+ ZX6wrXVYGLK5nafHB/iBlocplLcvr4rG54o/h4A6MyYaGHh0/mS9Lx/wyV/zY4WdpxRT 6xF5po+KI+S3CsqPfD4olazNjEMNQiXscmO8XfmFs4Vhnn9t9qaGG9PKwwRxrG1BrawG 7L+WiMUJe7/ekfKlKpLmPjErTKt5gr+9A5lPlfHyY4W/2d4Qxzs7RUwSd0jiCKH61so+ mnog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Qt80UJ/W"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f32si20962966plf.24.2019.03.27.12.19.30; Wed, 27 Mar 2019 12:19:45 -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="Qt80UJ/W"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388391AbfC0SIq (ORCPT + 99 others); Wed, 27 Mar 2019 14:08:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:50356 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388344AbfC0SId (ORCPT ); Wed, 27 Mar 2019 14:08:33 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2BB772063F; Wed, 27 Mar 2019 18:08:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710112; bh=xLT6k7kjlNbFvtR7VLCfH2Eq2uRTmbS90p2bYbo4kbM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qt80UJ/WRNp6kknph2wNyh60llhTFq7lsuY9QJUts+02pPu/5oDK4+OFymUCzGZQ7 5IYsOmhwFS4q5OY1NUPa6e03VyZQoCgMdA5byHTZYicqEXa4bmcm2vxciuYKbv1bV8 DridnQ/z4oxL7u/H3fvSi9lLbjiiXYOZd+xstfko= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Stanislav Fomichev , Daniel Borkmann , Sasha Levin , linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH AUTOSEL 5.0 201/262] selftests/bpf: skip verifier tests for unsupported program types Date: Wed, 27 Mar 2019 14:00:56 -0400 Message-Id: <20190327180158.10245-201-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stanislav Fomichev [ 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 2fd90d456892..9a967983abed 100644 --- a/tools/testing/selftests/bpf/test_verifier.c +++ b/tools/testing/selftests/bpf/test_verifier.c @@ -34,6 +34,7 @@ #include #include +#include #ifdef HAVE_GENHDR # include "autoconf.h" @@ -59,6 +60,7 @@ #define UNPRIV_SYSCTL "kernel/unprivileged_bpf_disabled" static bool unpriv_disabled = false; +static int skips; struct bpf_test { const char *descr; @@ -15946,6 +15948,11 @@ static void do_test_single(struct bpf_test *test, bool unpriv, pflags |= BPF_F_ANY_ALIGNMENT; fd_prog = bpf_verify_program(prog_type, prog, prog_len, pflags, "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; @@ -16099,7 +16106,7 @@ static bool test_as_unpriv(struct bpf_test *test) 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