Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7152808ybi; Mon, 8 Jul 2019 15:42:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqxTGTf/SEufGwTZZCQqdvhoX2YINDXKRCYogTSGT8kf8ZVEQC5g6JaCuWH/yT6dQ31Gafc6 X-Received: by 2002:a63:6103:: with SMTP id v3mr27571755pgb.161.1562625773017; Mon, 08 Jul 2019 15:42:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562625773; cv=none; d=google.com; s=arc-20160816; b=mUgCJpU27/2RhcpYYyZba8U/7vZNf22apCiU2mDSgMTp8fJojpK8x//mEbok9hEdWs Qm69gpxt7UBAeK1XWiqivrVhK24XwJjIVZt4Ku9vKeweXtXD+z+XPSVbSR69Fq1A/oGK HnjDBXRTH0us3Adg21jJY+tvE23csxLaQ8vLaK8o60ZY202889Nt187uHWvamImCNNOt Mi3x7ZUHeadVUi6pQjXQW/YWaMSaFhOu9DlA4qBifBInLQwdOOkgG1bf3vtorrqb9a3f Hkk/qtDGoMNbT3BQB3UN1biz8nFFcVZXDC7pQ3HfWQxp4ENa6nEWazI3htaL7fGWCcUN NYsg== 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=3geFFJ9tql4ZwrkQmT2Y6FVy9TSA0XcjotCe5RWiIWM=; b=Xet5fEm8d3UMsaUBzaXWZVF+eMi5l3yWbvGWffOBXLSvZuK2YlGObw4NWXVpR3/BZN GI56va5qYTOe6fKmN1AREMSi8g38MLIOOaRXjEAEL0SnGKiC4XGV0jdEuvwu2NgZjcZj +BoIxhMGG/G7WSmCPoo4S55W9ozWHrY8yk96KHISUi99rJ0blhELBTeoG6XzgIRTxqeI erAak5Cg6/ehfpDu7nbI8Ag0k1kki2EPIXcY8q7zQhrDrCHWxP6cMof+pMjUwIIiMol5 IODg3h3X3HPv0PxVnIzWDOqfkZ8JQoSTlDn1sQiHGcamh/8dkN+ENIYxMrOJb6zurJ6k LXmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kinvolk.io header.s=google header.b=W11kKcw1; 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 x24si21518903pfr.200.2019.07.08.15.42.38; Mon, 08 Jul 2019 15:42:53 -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=W11kKcw1; 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 S2389353AbfGHQbz (ORCPT + 99 others); Mon, 8 Jul 2019 12:31:55 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:34657 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388494AbfGHQbu (ORCPT ); Mon, 8 Jul 2019 12:31:50 -0400 Received: by mail-wr1-f68.google.com with SMTP id 31so1053488wrm.1 for ; Mon, 08 Jul 2019 09:31:49 -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=3geFFJ9tql4ZwrkQmT2Y6FVy9TSA0XcjotCe5RWiIWM=; b=W11kKcw12664L0TISI/sieWZFZRo6VanqFvi/sZiO58JX6zHqbOe5vVsLBGA/+5B+Y kKAtx9nfU9bBDJD3JcMKrs3s0vOlMoOeV4DK5ENYnVnXju2PxsleMeKcMdkefpydrt/X /qu3fMa+w+lGdlcWFfAf4e1+K73wTK7C4pWbc= 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=3geFFJ9tql4ZwrkQmT2Y6FVy9TSA0XcjotCe5RWiIWM=; b=hPFLO4gHFSe/yWm7SCLVPCeaJIjpY2pdkc1Y1JLCBzCvWCt+tri4r2nvIOGwP9Fhu8 VAJqMgAr28VnslrXSVxUQyUEu0UccUwplhrKPHbHivsDLlt4IFl2024FtDLyUcsT1Rnr wNv6ex/mUoPKALUHUjpFQsdHYTguZLgsmaDMbRt/jucEbRowt/8Rw5TqOMYSKZMQnGoQ 6bvNHvhGfEv0MttMB8DLTUZ8JKUnany0tkVyDnHfVgrZa8PcujTXPZvL/WKwPywuF38t xULhagXt+01hAJDaFtOmRV+kJYGW9xkVIdd3tsAUlFUoMD58PqRDS0VkbegQHQfMc0zK q22w== X-Gm-Message-State: APjAAAWOmP0xkB1GP0TH8UDlXOY6Kxid0Ejw1Yxj4C45zLQF5epu+8Xj 17SGOaSufyVeXwA8RStR0V7xVzXPYiDvHw== X-Received: by 2002:adf:ec0f:: with SMTP id x15mr19952633wrn.165.1562603508638; Mon, 08 Jul 2019 09:31:48 -0700 (PDT) Received: from localhost.localdomain (ip5f5aedbe.dynamic.kabel-deutschland.de. [95.90.237.190]) by smtp.gmail.com with ESMTPSA id e6sm18255086wrw.23.2019.07.08.09.31.47 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 08 Jul 2019 09:31:48 -0700 (PDT) From: Krzesimir Nowak To: linux-kernel@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 , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , netdev@vger.kernel.org, bpf@vger.kernel.org, xdp-newbies@vger.kernel.org, Krzesimir Nowak Subject: [bpf-next v3 02/12] selftests/bpf: Avoid a clobbering of errno Date: Mon, 8 Jul 2019 18:31:11 +0200 Message-Id: <20190708163121.18477-3-krzesimir@kinvolk.io> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190708163121.18477-1-krzesimir@kinvolk.io> References: <20190708163121.18477-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. Changes since v1: - Fix the "Fixes:" tag to mention actual commit that introduced the bug Changes since v2: - Move the declaration so it fits the reverse christmas tree style. 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 b8d065623ead..3fe126e0083b 100644 --- a/tools/testing/selftests/bpf/test_verifier.c +++ b/tools/testing/selftests/bpf/test_verifier.c @@ -823,16 +823,18 @@ static int do_prog_test_run(int fd_prog, bool unpriv, uint32_t expected_val, __u8 tmp[TEST_DATA_LEN << 2]; __u32 size_tmp = sizeof(tmp); uint32_t retval; + int saved_errno; int err; 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