Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp4044963ybd; Tue, 25 Jun 2019 13:03:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqwy3TPJ/oGeweGN/up+0mti8s3CU/UYcSGuSAKkLEYKC1kjMIwn9EC09yQZmaJlZzeJIrHc X-Received: by 2002:a63:e156:: with SMTP id h22mr10229689pgk.370.1561493029430; Tue, 25 Jun 2019 13:03:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561493029; cv=none; d=google.com; s=arc-20160816; b=ON1KOXrtfx+yNLj/C1JtLBTSZUliQsQK7Z7jqHGHmQ0brB9AwnRY85E37rNVC3MRvQ DIdnJIJjhJJw1TmkalimL3WYuX8byljlE07J3yFQFmQoJ5CABzlGQmC+74KkcwRTdMLC wKG3gat+1Z+Vn7IWh41GfKc452X4i0X3ADJ0waU/WIjyA+uXoRiXUDgy9IFphljKBcsB xd3FEAGHQBljUoHV5azuQjUemit5hKd0m5yE1aHq6mXkumUblVCL5OktJLqkirnxYB+g rvB2dGufMPMkopUZslywlqOmroWrV2Dj7oLpBec5sQPADX83NJlMJTaa1bITXUZdKPmv niDA== 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=gF+TApHT5g/voE3vYeHrjhE0fjt+hIapyPZdSdt5oAQ=; b=kzuFnvduGXE84fgkWUaS2CO0NDObi6GEMpYNF2KUZZiv8/zmooJj88rul6igBhpgHl +3wnwVB3peHUvKW+fFtI9nW9hEU1HF9JjxNMSRe1TU5a0a4yqCznHOHuEkGea/4gYhqX StkGrApnVNPtWst0Y33lNVXoea5eGl2y7q9GmSkBzdNgOlRLoPsK61BV6Z0Z2LVrAcNP 9l2eqoLNdZ25QRjts7TXIRFuSAX/owkVvWYH7eUn2LCrsMjyKqFoH03lUZ/mTXcADOZq mIaBUCSxRtH7KuBGVlsgNIwDn3AkOhxN0vSVFUJk47S57SBrYaPH7knCmPGl+7ihHLBE wZ0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kinvolk.io header.s=google header.b="csn54bR/"; 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 x11si861877pll.42.2019.06.25.13.03.33; Tue, 25 Jun 2019 13:03:49 -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=@kinvolk.io header.s=google header.b="csn54bR/"; 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 S1730281AbfFYTnn (ORCPT + 99 others); Tue, 25 Jun 2019 15:43:43 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:37286 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728878AbfFYTmu (ORCPT ); Tue, 25 Jun 2019 15:42:50 -0400 Received: by mail-wr1-f67.google.com with SMTP id v14so19233981wrr.4 for ; Tue, 25 Jun 2019 12:42:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kinvolk.io; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gF+TApHT5g/voE3vYeHrjhE0fjt+hIapyPZdSdt5oAQ=; b=csn54bR/un7yHoLCBsM3gUToVx0AmYE5K7Oy2aGEZPtqU0mq7XujTVNDzqowgyHVSG FdUGlOSmw9CAUCznG54Ck4vg54uHBUVPthrSIjqSlIT6GJyCz0B9DsnGMBxNd5Y6ZuZi BLr+I6RmTPkWGUMyzCJsjx+r6WN1t7VsTCIJ8= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=gF+TApHT5g/voE3vYeHrjhE0fjt+hIapyPZdSdt5oAQ=; b=AmZ8CgM9UnaJkYiyhk+/SauAGh4M19GOpzW22qBHQshH9LB6jyoWde96On8uYtNfCm Nm6PDFg95z9kmfY53dxWcUgit4MazvUF4ZVUL6f75uRwM3MvjvwdJt4i+TgJDu+glcZr D2wAI4klw3zruOyIQFlun1S3+94hjnxknvAkg72pkms9hWwpglx7G614PY5ZsgqSIcFq vNUtx9oD+j3Yy4xa6u/ngscph0glDS8sUBWs8KZ5s8VyH3UOvdY0SORyQjbtQBf8fZab jYmM8sWI+4hrMF2qInTnwPSQnhjcrlwe0mJ5DsJdX3QhtMPh5VgdPGiNkERiDfSk6pbg j6cg== X-Gm-Message-State: APjAAAVPi4QONHfllyK00L8UE8SB3Dt+SMjqi3hko2rcjprLk9jkcbuH 0qwx7UzF06+InWhk6xNSf4FzCg== X-Received: by 2002:a5d:5692:: with SMTP id f18mr58429326wrv.104.1561491767958; Tue, 25 Jun 2019 12:42:47 -0700 (PDT) Received: from localhost.localdomain (ip5f5aedb6.dynamic.kabel-deutschland.de. [95.90.237.182]) by smtp.gmail.com with ESMTPSA id q193sm84991wme.8.2019.06.25.12.42.46 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 25 Jun 2019 12:42:47 -0700 (PDT) From: Krzesimir Nowak To: netdev@vger.kernel.org Cc: Alban Crequy , =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , linux-kernel@vger.kernel.org, bpf@vger.kernel.org, Krzesimir Nowak , Stanislav Fomichev Subject: [bpf-next v2 03/10] selftests/bpf: Avoid another case of errno clobbering Date: Tue, 25 Jun 2019 21:42:08 +0200 Message-Id: <20190625194215.14927-4-krzesimir@kinvolk.io> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190625194215.14927-1-krzesimir@kinvolk.io> References: <20190625194215.14927-1-krzesimir@kinvolk.io> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 8184d44c9a57 ("selftests/bpf: skip verifier tests for unsupported program types") added a check for an unsupported program type. The function doing it changes errno, so test_verifier should save it before calling it if test_verifier wants to print a reason why verifying a BPF program of a supported type failed. Fixes: 8184d44c9a57 ("selftests/bpf: skip verifier tests for unsupported program types") Cc: Stanislav Fomichev Signed-off-by: Krzesimir Nowak --- tools/testing/selftests/bpf/test_verifier.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c index 12589da13487..779e30b96ded 100644 --- a/tools/testing/selftests/bpf/test_verifier.c +++ b/tools/testing/selftests/bpf/test_verifier.c @@ -867,6 +867,7 @@ static void do_test_single(struct bpf_test *test, bool unpriv, int fixup_skips; __u32 pflags; int i, err; + int saved_errno; for (i = 0; i < MAX_NR_MAPS; i++) map_fds[i] = -1; @@ -894,6 +895,7 @@ 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), 4); + saved_errno = errno; if (fd_prog < 0 && !bpf_probe_prog_type(prog_type, 0)) { printf("SKIP (unsupported program type %d)\n", prog_type); skips++; @@ -910,7 +912,7 @@ static void do_test_single(struct bpf_test *test, bool unpriv, if (expected_ret == ACCEPT) { if (fd_prog < 0) { printf("FAIL\nFailed to load prog '%s'!\n", - strerror(errno)); + strerror(saved_errno)); goto fail_log; } #ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS -- 2.20.1