From patchwork Tue Sep 12 12:06:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artem Savkov X-Patchwork-Id: 138182 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp409602vqx; Tue, 12 Sep 2023 06:32:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHNoEKNMvVN7ff1psPIYezD+kuySGK+IfEKqdx4lKNKRzbuwNGgx/xhsg1zalv8jbEd/2gz X-Received: by 2002:a05:6a00:4395:b0:68f:e0c2:6d46 with SMTP id bt21-20020a056a00439500b0068fe0c26d46mr3274234pfb.23.1694525531922; Tue, 12 Sep 2023 06:32:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694525531; cv=none; d=google.com; s=arc-20160816; b=LzCrFNjllQ9EOOaou8CtKcbFNNaC5d4KcB46YDt5GIfQ4xY7XHLAfXOE2DGzEOMAAZ WfuyzDrVNX1vDmNwqWa/3gu933li0DVwMgHmy4CTGwNLAQnHMltTLR1cf1eUUh7WqVfa itv92GFCeCAVnqLaXhsEcs6pIBwvvYQf4EmdxNGgXeyG9UzW/lgCmI2iNxbOAu4Sg8Tp cmwsoSI65b0nWnlwb9m7JFccQ6iPdDzUyWI4NqO2SQqliE2ybR6HunGFm2+Nrv7cHZbD gp7ok65qDKCmrsS/7CZ4uzbmw9CwLmeM6qWTuDszksZwPKV7Zss1BP7RE+5gR2V/K0tw A6Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=tX6yWckEp0zjVKcWR1lfoEzSymqYQ6Dx9WYErV4NIQ4=; fh=W5BQR9M8ylWH4nBwKUJT9IGPI8zh2NKD5GLlSruHv00=; b=Fda9cUz12KLw6LxIuE6tFJDe0d7RocLn4QPe4za3n6BW/cj24B7JPwN4ITCxZwhCbI 40/w0muY28pluQ2A3koTB03EIpfXMkz37Epd09MFnz710WPKtCyDPzlLWe1ae8KVxpIw UvdVuJCsyxAwXd+eTVAguo3LSt/luosuJg6xJjLox/jw2BplzhVgNgr5GZfNT0eKSH7H uis7TrLM58c4qeGjTl4QBrLROSUFETgNhLd32Vglx703mwSJgYJ6Rc8xGDqUxCBxg/Dm ajlSkU6bFtKyOkIhNvNC4QPNEi8Vvz3tqqyKGQHsX66ZpQ9h377++7OoSCPNI7SrxEAV SRZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=day7dsfJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id r32-20020a634420000000b00573ff094485si7994001pga.250.2023.09.12.06.32.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 06:32:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=day7dsfJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 87BEF80F7295; Tue, 12 Sep 2023 05:07:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234656AbjILMHf (ORCPT + 37 others); Tue, 12 Sep 2023 08:07:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233436AbjILMH2 (ORCPT ); Tue, 12 Sep 2023 08:07:28 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4209F10D3 for ; Tue, 12 Sep 2023 05:06:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694520398; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=tX6yWckEp0zjVKcWR1lfoEzSymqYQ6Dx9WYErV4NIQ4=; b=day7dsfJO+7i8dK9Q7byY+2g70qqW4yjnzf3reiSvBqJDMLlFiKBnVmHhgybAIkonvadEg U5xIYdUkxtUfa542FZi/86M+Yta017IlX2dZbT+ZK1bq0D6XihkJa6e7sAmiHs4CjtL2q2 cicC8GbZXULE+gc4yJjwKKZ/aAu0Hvg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-606-SxgM-UXoMPmCmZdOPiUJOQ-1; Tue, 12 Sep 2023 08:06:35 -0400 X-MC-Unique: SxgM-UXoMPmCmZdOPiUJOQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 952668D3BC3; Tue, 12 Sep 2023 12:06:34 +0000 (UTC) Received: from alecto.usersys.redhat.com (unknown [10.43.17.26]) by smtp.corp.redhat.com (Postfix) with ESMTP id 55D5710F1BE7; Tue, 12 Sep 2023 12:06:33 +0000 (UTC) From: Artem Savkov To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , bpf@vger.kernel.org, netdev@vger.kernel.org Cc: Eduard Zingerman , linux-kernel@vger.kernel.org, Artem Savkov Subject: [PATCH bpf] selftests/bpf: fix unpriv_disabled check in test_verifier Date: Tue, 12 Sep 2023 14:06:31 +0200 Message-ID: <20230912120631.213139-1-asavkov@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 12 Sep 2023 05:07:54 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776838804255825936 X-GMAIL-MSGID: 1776838804255825936 Commit 1d56ade032a49 changed the function get_unpriv_disabled() to return its results as a bool instead of updating a global variable, but test_verifier was not updated to keep in line with these changes. Thus unpriv_disabled is always false in test_verifier and unprivileged tests are not properly skipped on systems with unprivileged bpf disabled. Fixes: 1d56ade032a49 ("selftests/bpf: Unprivileged tests for test_loader.c") Signed-off-by: Artem Savkov Acked-by: Eduard Zingerman --- tools/testing/selftests/bpf/test_verifier.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c index 31f1c935cd07d..98107e0452d33 100644 --- a/tools/testing/selftests/bpf/test_verifier.c +++ b/tools/testing/selftests/bpf/test_verifier.c @@ -1880,7 +1880,7 @@ int main(int argc, char **argv) } } - get_unpriv_disabled(); + unpriv_disabled = get_unpriv_disabled(); if (unpriv && unpriv_disabled) { printf("Cannot run as unprivileged user with sysctl %s.\n", UNPRIV_SYSCTL);