Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp4044931ybd; Tue, 25 Jun 2019 13:03:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqx1e3Z2UM3j0evrimAWxxX1XNii6VP1aajxhSQmOLhhjKXMXEra2OX+6Qvt08UmAkZ6x8yq X-Received: by 2002:a17:902:aa5:: with SMTP id 34mr563778plp.166.1561493027503; Tue, 25 Jun 2019 13:03:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561493027; cv=none; d=google.com; s=arc-20160816; b=k9DbipRsd7YfutPPX/gtrSHVF3mudxs22TO8du00vCpukqzlF9yfdFerOWZU5VUaTc U7kFhpT6OvLnH8HEJsKcDLDpJTSjH25/TGNySSISFvMa0WvYurHtGu8Roc5z2hD0f9Yo 3B2prN4JHVG++Z4TVc/ihCxQjdT70Kq5SqKEs8sb/cmNyYS/GwuMxgB0VBk68GhIL6Hh ff3tXVbVKgzoxLks1fup8BwQA4QMjgaXh7A8yqw8fXuGA0RaEgbbF90QbffQrnFzhaWK F6+uBTGm25G1VqBNKGvohuIUmDC3s6+Vt38O4q9tiD7QNBmq61cEs3q7qhDG3a96CqWG Ka3Q== 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=nCISGYpVhbDUZBooq11pFuU2+JLufihV8fmI2MlKQk4=; b=vay6Z23h9nfQgYV6RstbUbR5d9wu0Nj17c0ScNLV2cknR4EOLSxGVMa2breSeWpbzO QHF0qKGH5/BKzD5X7dcBRRTFSz9GNfQPjJIIqofuDRW/x8wp63WRtoZL4bT6xchDQddf x/7aqv2ZBNcK1x9lBh53pMaNBKR5/IWVfGhA48JpPY1R4fdpVUGcNPF5afdTmOwhRk43 fThgomw7vRyY5xF0Qht2cAGtDqPDKbqMIQeKuV2THVJenr3QAk6LLTjx2dXpArvP5YLc cT6dNho96aJpQvCfLEZjK3AcAns+SV28b6fKBeVOuqwNRwOMSsOIGeiAiPiqzMwGRUL5 SbUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kinvolk.io header.s=google header.b=V3ngQTsa; 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 w3si1013648plb.35.2019.06.25.13.03.31; Tue, 25 Jun 2019 13:03:47 -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=V3ngQTsa; 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 S1729088AbfFYTmu (ORCPT + 99 others); Tue, 25 Jun 2019 15:42:50 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:41300 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728768AbfFYTmt (ORCPT ); Tue, 25 Jun 2019 15:42:49 -0400 Received: by mail-wr1-f66.google.com with SMTP id c2so19208167wrm.8 for ; Tue, 25 Jun 2019 12:42:47 -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=nCISGYpVhbDUZBooq11pFuU2+JLufihV8fmI2MlKQk4=; b=V3ngQTsaLqIqF7TzFh6XNjh79Gh1EyL5uZaziiNjq0FLjD3fH1sqkMEytNv8O3YwPd DVEeJlvoUws0v0y8oOxwkz1XaTgwrRGLPTZXz47swy6hZxA2kwBzXr/0T2m6BTfs7SVd rSBkXge4VJk/T/eh1joDvCtlj4xufcLDnC9D0= 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=nCISGYpVhbDUZBooq11pFuU2+JLufihV8fmI2MlKQk4=; b=Kq4CiDS8cZ0l0l+69BEtr6A27DYMdTNEI3S8fk836cxXjeQEFpfwQWAYG+ol+PvQqc pNVaKgksQt8uO1yE/seIc5rTDX1c31yJ46NMelGB0ZD67fduKpx/II81T5qxcjRlF5LI 0aVWP/CW7770kzyxuGToNXnHgdKVDSp5MAt9TXeQgYLmXj51rYvXYyxoZ2gwTZ7OUuJD qvx7f3aFK/zF6bDzL+eUP11gNX8Ynii+Il+mhPilOaGBcjLFpDNtx2Ouk9sFO098GdQJ O2gGeV4ifo1kyRudOhe7JEXTF3fdjO4/9swPjtmNX3TGnUgxfJULRWBRoOKNau+coAJ5 WGeA== X-Gm-Message-State: APjAAAXQyfmnNc/XzQA6iKuUjJoiUWWfJKjBz+xiZFUkRnL37f5VfEvJ btbK1HzZIT57W8JpyFBUg8BsUA== X-Received: by 2002:a5d:4f8a:: with SMTP id d10mr33245893wru.13.1561491766892; Tue, 25 Jun 2019 12:42:46 -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.45 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 25 Jun 2019 12:42:46 -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 Subject: [bpf-next v2 02/10] selftests/bpf: Avoid a clobbering of errno Date: Tue, 25 Jun 2019 21:42:07 +0200 Message-Id: <20190625194215.14927-3-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 Save errno right after bpf_prog_test_run returns, so we later check the error code actually set by bpf_prog_test_run, not by some libcap function. Cc: Daniel Borkmann Fixes: 832c6f2c29ec ("bpf: test make sure to run unpriv test cases in test_verifier") 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 9e17bda016ef..12589da13487 100644 --- a/tools/testing/selftests/bpf/test_verifier.c +++ b/tools/testing/selftests/bpf/test_verifier.c @@ -824,15 +824,17 @@ static int do_prog_test_run(int fd_prog, bool unpriv, uint32_t expected_val, __u32 size_tmp = sizeof(tmp); uint32_t retval; int err; + int saved_errno; if (unpriv) set_admin(true); err = bpf_prog_test_run(fd_prog, 1, data, size_data, tmp, &size_tmp, &retval, NULL); + saved_errno = errno; if (unpriv) set_admin(false); if (err) { - switch (errno) { + switch (saved_errno) { case 524/*ENOTSUPP*/: printf("Did not run the program (not supported) "); return 0; -- 2.20.1