Message ID | 20230602013358.900637-8-jhubbard@nvidia.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp731939vqr; Thu, 1 Jun 2023 18:46:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5CXrr5iArlI/jYrxQegAgLc89zgEEFT+D/Rm4DReG9pkFMsroUoadImtukZtaODOOghcsB X-Received: by 2002:a5d:9a8f:0:b0:774:7cdb:1fe4 with SMTP id c15-20020a5d9a8f000000b007747cdb1fe4mr1053858iom.13.1685670399640; Thu, 01 Jun 2023 18:46:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1685670399; cv=pass; d=google.com; s=arc-20160816; b=wDLb0jMB8hUjnJ3xNLnC/lb/AnoRP8BirPsRo+PFSyXq2AdN8C+g1ZwXqcEn46ut/p fbTkosgkEiXe28bYYMPFOr7oc4uhCjsACgNav12vTYCDetYYujKacPqmSdK/HL9ua9eg NhVIzbuxHIjrAML7G73ZqKW4ID+KeeHoBeyuNyjs/+JrYmqe5y61OmF+w2kozEaSZW5J o9vw9QcZ5ZWklNukKGouWlsweU/lLxE7EwLi4hr3ho91rzxQwphDxvAbhAMhCNZ3ht63 HVONnTapLfUAE9mMjVYIA04VaLrF1O01qyG/u5P7bOVnPNv5T9J4HXzippLjG9/y45Cq 0cfQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LHHg0GeUqQ9D6ypa+gYCxOv4uIVN5myD0EE5yivIW5Y=; b=nokXxhbKy5AJTSu7prK4C5cT4HvKdh/9BuWRMvAGGuf4XM9OFhzCyd1oElyaW4YPAk RfVBojEKgiiJsXg2qwMgWvWpunDwMg1mCvt982J7q5mfnlldyHVk0sUU1FmwBOg0DLBg txvKlNNo0bazPv/BkKrOHAWFhswLQYY2pySW1FWJEWDrSSky+Xk8z+ak7Sei+VsHTU3e m7JSTfjk1QLl9yQ+giNF86Q1dlOAHagq1WblxXGXikT4JJs2kEKwOO/LAWXhxrMMAUlB KZSuRmri188t54OM07RSYKJrklwGUVF6IQnpD/OYb6SvhnQhQr1mVEGUiJDiP+v+iHrb fRkA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=EA9duJZB; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j70-20020a638b49000000b005348954e07asi182598pge.1.2023.06.01.18.46.27; Thu, 01 Jun 2023 18:46:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=EA9duJZB; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233747AbjFBBe4 (ORCPT <rfc822;limurcpp@gmail.com> + 99 others); Thu, 1 Jun 2023 21:34:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233603AbjFBBen (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 1 Jun 2023 21:34:43 -0400 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2045.outbound.protection.outlook.com [40.107.212.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92CAA132; Thu, 1 Jun 2023 18:34:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PZdXS6Bxm7LxHhLxBKotR1fB9vf/hnxqV7YUAWH0kzVHNCHXJI1hlTQeMN+DNYGuZAIfbCoGREY4XiWFynaU94WpyjOmFxzP3RZNlrEKuPOSd1Z0QHhAOs2f+LyJkTFBIhdD3cnEJYTXMSCVHLWMdnuuglUDOnL2KX8aKwI3q89L/g7ZjeQc0Inhb1xHGpH4X1PdFWlwhBEZF9RIwnaetWfSYMgFBhcKlDITmTSFGU90q5lC3P9NREkho12UYGTeBm7b14xMtX0/0AF3r8EBq3qJM0fvpUC1ryQU/WN8OR6MbXsOf8Q0bxfyfPFSnhVPdgh/fmHQMuaa1TXAEziUfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LHHg0GeUqQ9D6ypa+gYCxOv4uIVN5myD0EE5yivIW5Y=; b=Jk2N4WUD28Qcd9Tl3S8/p7Q+MBdWGiE/8+K5vDhr/CsG+GMhxtsZ4Mxb6HiDol1l1HPqSRKwHDjFAnWYgEYaXqtKm1cHERf203EQfWm6MQKfEP65WDfigqi3EQ0zkvKuOz2o3Sag/JQa/HwbkbFEYaDAeDc68GCgE8/R5JmBypeLSwU+uO3UgXhy0+pmLxR//1AISr8w9kUEdmkJroJiCDNWYCM7QDwKMHxmGJPHfe134grlL/KH4HV15JmWFMaobJvWX3m/mkZGqI0QgkXnsmieJlY4pWUBREjhF2Ujg3PR9goCrjQrbjtwh2YSJL4q3aVNVFh4rRirtTqX0GBsig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=linux-foundation.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LHHg0GeUqQ9D6ypa+gYCxOv4uIVN5myD0EE5yivIW5Y=; b=EA9duJZBZustQFBioeABrIah4pKPWXzqnl+1RBmuBwW3kL2HZOyyds4gVfvp2oApaR6Slep4LyKZYOH0xJX7ngHiMYMfiHRMmTpBuvfrMIMG5GzhghhllesuZwT56JqOMIg5QYF3ptF31NnwsoNcALkc3wQkPMH4X2U39SxZIZhxNMni2/+hm9FLqg1OlHY2XnGakzLCQ28AmEM7IvFtusqtU3hvUWMnESH081BNJQq8ziIW+lfNOP4taQN3z0oOiCdE12Qt1eXPjV9BbriT+D2Fbu57KJqsHnh4DoC0qW3MIUBtBBVjcRi4xVXT34cuEEo/jB/GpHsL7lOSyE/0DQ== Received: from MW4PR03CA0257.namprd03.prod.outlook.com (2603:10b6:303:b4::22) by DS0PR12MB7777.namprd12.prod.outlook.com (2603:10b6:8:153::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.27; Fri, 2 Jun 2023 01:34:40 +0000 Received: from CO1NAM11FT070.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b4:cafe::f1) by MW4PR03CA0257.outlook.office365.com (2603:10b6:303:b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.23 via Frontend Transport; Fri, 2 Jun 2023 01:34:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CO1NAM11FT070.mail.protection.outlook.com (10.13.175.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.23 via Frontend Transport; Fri, 2 Jun 2023 01:34:39 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 1 Jun 2023 18:34:23 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 1 Jun 2023 18:34:23 -0700 Received: from blueforge.nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Thu, 1 Jun 2023 18:34:22 -0700 From: John Hubbard <jhubbard@nvidia.com> To: Andrew Morton <akpm@linux-foundation.org> CC: David Hildenbrand <david@redhat.com>, Peter Xu <peterx@redhat.com>, "Shuah Khan" <shuah@kernel.org>, Nathan Chancellor <nathan@kernel.org>, <linux-mm@kvack.org>, <linux-kselftest@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>, John Hubbard <jhubbard@nvidia.com> Subject: [PATCH 07/12] selftests/mm: set -Wno-format-security to avoid uffd build warnings Date: Thu, 1 Jun 2023 18:33:53 -0700 Message-ID: <20230602013358.900637-8-jhubbard@nvidia.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230602013358.900637-1-jhubbard@nvidia.com> References: <20230602013358.900637-1-jhubbard@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT070:EE_|DS0PR12MB7777:EE_ X-MS-Office365-Filtering-Correlation-Id: d0daccb8-1f97-4620-2a75-08db63098865 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Jgp4J2ItNaBKBZAB0bFP1EdveiZqOCxTamGMlUkrlMAbqxeXyuptjWOyebofMXJZtVSAEbJjeMorLo8L0oL3ueYRkpb6tGaFx49wCNBpFlOcZL0ooQb7afRyuI2azFuhfg+6XxsPCB57W/HqkZfcL3fvhFE2ieNOC/D3sBRK0VqbORcR652bb2QUtbovEeXlqNn7xFzx3khDoxMj94ajtDplqGw791YRSovDRnuWM/Ib9r7Q3cFgXRI+VqK0tlrba/PmCTIOAN7XdeNteo1n62YcAKBOFp0NJNYTu7bOGSywP0/ZGG0x3KUc91Zg0mELZWCVdvBov4t2MiV86GgpTPo5yrplNecwHlS58X0IpVMtuHoVFrm6jnB/d6b0o8ft01mg0iGxfemCM0+q8wFeewHkv5p+ggQ01pNeXUxWvB2MOCzXOzL/Z0qy+lrZIouwA8I3UMie+ytDFaKlvEPIXWsJqM2uREHlncronweuA80aDb545mjMrvw1bVaZ4fHepw7su1KvBLJTVZOfAB98ihLiT45V2gApPAGR5wxaY3PIyYxXngZvVWGI8dMZ2S0T4R5kCZ1P/6SncvC60Jsk3dLMRMs/lwnOyTOpjEY7aOj0ZOYyHfx6zb0rsXJS0slvcgBSLnNjX3BH0xKTN/BPndKWlQH9taXHVVjWfs+9Q4eFsJPTkOCd3qyoq1m5r4cToW41BPrjOGnPlJI3ow47YL6PVS9esQYOXVCte1cVwj0hVg1+edwJzPiHhJ3WyV44 X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(376002)(346002)(136003)(451199021)(46966006)(40470700004)(36840700001)(6666004)(426003)(40460700003)(336012)(5660300002)(26005)(7636003)(15650500001)(82740400003)(83380400001)(2616005)(8676002)(1076003)(186003)(2906002)(36860700001)(40480700001)(47076005)(6916009)(107886003)(356005)(54906003)(41300700001)(7696005)(4326008)(316002)(70586007)(82310400005)(70206006)(36756003)(8936002)(86362001)(478600001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2023 01:34:39.5837 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d0daccb8-1f97-4620-2a75-08db63098865 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT070.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7777 X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767553524997588808?= X-GMAIL-MSGID: =?utf-8?q?1767553524997588808?= |
Series |
A minor flurry of selftest/mm fixes
|
|
Commit Message
John Hubbard
June 2, 2023, 1:33 a.m. UTC
The uffd_test_start() is perhaps a little too elaborate about how it
dispatches tests, leading to a clang warning that looks roughly like
this:
"uffd-unit-tests.c:1198:20: warning: format string is not a string literal
(potentially insecure) [-Wformat-security] ...note: treat the string as
an argument to avoid this.
uffd_test_start(test_name);
"
However, it doesn't seem worth it to rewrite the way uffd_test_start()
works, given that these tests are already deeply unsafe to begin with.
Fix this by just disabling the compiler warning, but only for
uffd-unit-tests.
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
tools/testing/selftests/mm/Makefile | 2 ++
1 file changed, 2 insertions(+)
Comments
On 02.06.23 03:33, John Hubbard wrote: > The uffd_test_start() is perhaps a little too elaborate about how it > dispatches tests, leading to a clang warning that looks roughly like > this: > > "uffd-unit-tests.c:1198:20: warning: format string is not a string literal > (potentially insecure) [-Wformat-security] ...note: treat the string as > an argument to avoid this. > uffd_test_start(test_name); > " > > However, it doesn't seem worth it to rewrite the way uffd_test_start() > works, given that these tests are already deeply unsafe to begin with. > > Fix this by just disabling the compiler warning, but only for > uffd-unit-tests. > > Signed-off-by: John Hubbard <jhubbard@nvidia.com> > --- > tools/testing/selftests/mm/Makefile | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile > index 23af4633f0f4..473bf1811552 100644 > --- a/tools/testing/selftests/mm/Makefile > +++ b/tools/testing/selftests/mm/Makefile > @@ -170,6 +170,8 @@ $(OUTPUT)/ksm_tests: LDLIBS += -lnuma > > $(OUTPUT)/migration: LDLIBS += -lnuma > > +$(OUTPUT)/uffd-unit-tests: CFLAGS += -Wno-format-security > + > local_config.mk local_config.h: check_config.sh > /bin/sh ./check_config.sh $(CC) > Maybe the following will silence the warning by removing test_name completely: --- tools/testing/selftests/mm/uffd-unit-tests.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c index 269c86768a02..15c76ce972be 100644 --- a/tools/testing/selftests/mm/uffd-unit-tests.c +++ b/tools/testing/selftests/mm/uffd-unit-tests.c @@ -1149,7 +1149,6 @@ int main(int argc, char *argv[]) uffd_test_case_t *test; mem_type_t *mem_type; uffd_test_args_t args; - char test_name[128]; const char *errmsg; int has_uffd, opt; int i, j; @@ -1192,10 +1191,8 @@ int main(int argc, char *argv[]) mem_type = &mem_types[j]; if (!(test->mem_targets & mem_type->mem_flag)) continue; - snprintf(test_name, sizeof(test_name), - "%s on %s", test->name, mem_type->name); - uffd_test_start(test_name); + uffd_test_start("%s on %s", test->name, mem_type->name); if (!uffd_feature_supported(test)) { uffd_test_skip("feature missing"); continue; Still gives me Testing register-ioctls on anon... done Testing register-ioctls on shmem... done Testing register-ioctls on shmem-private... done Testing register-ioctls on hugetlb... skipped [reason: memory allocation failed] Testing register-ioctls on hugetlb-private... skipped [reason: memory allocation failed] ...
On 6/2/23 03:15, David Hildenbrand wrote: ... > Maybe the following will silence the warning by removing test_name > completely: > > > --- > tools/testing/selftests/mm/uffd-unit-tests.c | 5 +---- > 1 file changed, 1 insertion(+), 4 deletions(-) > > diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c > index 269c86768a02..15c76ce972be 100644 > --- a/tools/testing/selftests/mm/uffd-unit-tests.c > +++ b/tools/testing/selftests/mm/uffd-unit-tests.c > @@ -1149,7 +1149,6 @@ int main(int argc, char *argv[]) > uffd_test_case_t *test; > mem_type_t *mem_type; > uffd_test_args_t args; > - char test_name[128]; > const char *errmsg; > int has_uffd, opt; > int i, j; > @@ -1192,10 +1191,8 @@ int main(int argc, char *argv[]) > mem_type = &mem_types[j]; > if (!(test->mem_targets & mem_type->mem_flag)) > continue; > - snprintf(test_name, sizeof(test_name), > - "%s on %s", test->name, mem_type->name); > > - uffd_test_start(test_name); > + uffd_test_start("%s on %s", test->name, mem_type->name); > if (!uffd_feature_supported(test)) { > uffd_test_skip("feature missing"); > continue; > Yes, that does clean up one of the two warnings nicely. I'll do that instead -Wno-format-security, thanks. That still leaves another similar warning that fires for "errmsg". However, that one is easily fixed because the associated macro turns out to be unnecessary, because all callers pass a simple char* string, without any format specifiers. So just turning one macro into a C function fixes that, leaving us with this (plus your fix from above): diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c index 269c86768a02..04d91f144d1c 100644 --- a/tools/testing/selftests/mm/uffd-unit-tests.c +++ b/tools/testing/selftests/mm/uffd-unit-tests.c @@ -109,12 +109,11 @@ static void uffd_test_pass(void) ksft_inc_fail_cnt(); \ } while (0) -#define uffd_test_skip(...) do { \ - printf("skipped [reason: "); \ - printf(__VA_ARGS__); \ - printf("]\n"); \ - ksft_inc_xskip_cnt(); \ - } while (0) +static void uffd_test_skip(const char *message) +{ + printf("skipped [reason: %s]\n", message); + ksft_inc_xskip_cnt(); +} I'll send that in a v2. thanks,
diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile index 23af4633f0f4..473bf1811552 100644 --- a/tools/testing/selftests/mm/Makefile +++ b/tools/testing/selftests/mm/Makefile @@ -170,6 +170,8 @@ $(OUTPUT)/ksm_tests: LDLIBS += -lnuma $(OUTPUT)/migration: LDLIBS += -lnuma +$(OUTPUT)/uffd-unit-tests: CFLAGS += -Wno-format-security + local_config.mk local_config.h: check_config.sh /bin/sh ./check_config.sh $(CC)