Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6767450rwd; Tue, 6 Jun 2023 01:22:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ46Pn7QvWExxVapFrMRL0USR9w/OUL55I/dM5QDV2ZGfttRumxDza8lvHMQ9izjQ3jGbVI6 X-Received: by 2002:ac8:574b:0:b0:3ef:2c3a:faa3 with SMTP id 11-20020ac8574b000000b003ef2c3afaa3mr1278925qtx.17.1686039723251; Tue, 06 Jun 2023 01:22:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686039723; cv=none; d=google.com; s=arc-20160816; b=jKuCCZLN7N/Aw9Wyg3/SPa+kIbzcCJxCsGJxCFIz3b46QmIbJfGBCC80WmNf+uk7LG IeFJLBrreO5K+aoB7kpmFU2lR927nSoxe8GWbiHn0dsgCFuN5yien82+ASQWL+fyyTcD grJlh0igUm7zZ0WMhIlxR6/0RQNJZT2o2UBHX8+XiVj51XwXV45wdhYD/H+42JlO/okl QmIC0IbUTNCh2I/8z7/N/jiLTQfy/awi9Q35OVu6X33CXVB8NoAXcb1mRGsnkufMfDEz EndUX2TRjSsrxDMlBA2P7xEU/9N9+leZuVkxci/g5AOqbQtWzKLc9sc45uk2Kw/eAuab bvsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:cc:user-agent:mime-version :date:message-id:dkim-signature; bh=Ql8BYuIEdudU2Zg10bEE8zLu5uFEn9ubhHUGB4SdJsI=; b=B9kOynrVJdsY0ea/F2IfOcA9W9m/POTca5w4QmoFQAiK/grOkZeIIGd+huJ6iyk/ya VROnqJu5yvBVQRh2lZui2fVzfQsmJd1fk/B56hcmHx2e1Rddms1l+Thw3M7Hod3g7JyE HfBrfMdKzaUEJuonew54LjOKn+2cF5PjYCKPauD3/S9JMjpVfjSDZxV3SCZRLeMBtthY yKWOFBD9F1gipYbcQ8qpuNFYQTF3OrfhfgkGLYGAd0gmrcYAqbdUN45mpm7jAUIE/SDD g04RWI8SLOSp5Ure7UhPIjyfaQhoNePyYm+nf0mBghgavzDYlM8oksH1ptKRRGlq6u6G 5O0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ZhwgoBkN; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h12-20020ac85e0c000000b003e39654640bsi6005980qtx.446.2023.06.06.01.21.48; Tue, 06 Jun 2023 01:22:03 -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=@collabora.com header.s=mail header.b=ZhwgoBkN; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236256AbjFFH5f (ORCPT + 99 others); Tue, 6 Jun 2023 03:57:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236149AbjFFH5T (ORCPT ); Tue, 6 Jun 2023 03:57:19 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CB2B30E0; Tue, 6 Jun 2023 00:54:39 -0700 (PDT) Received: from [192.168.10.48] (unknown [119.152.150.198]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: usama.anjum) by madras.collabora.co.uk (Postfix) with ESMTPSA id E1FA96606E98; Tue, 6 Jun 2023 08:54:34 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1686038077; bh=pIGKvYGDq4T5r3V/OOhF4iPvxLXerjQw652JcJRg8XM=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=ZhwgoBkNEfc858rFfDwHEziWJCXBGbCiT9KcASsdCA1q+WF96wi7NcL913qqnfzWU OPeqri3jdY5sJsn5g+juVYRmfcgDM+vSgOcFxtV7FYAMN3fpM5YyQIihMqehaRnDZp MGfQ3GHISalJizfUUjfbhgJZz+UCCD+iLcqz3vHtO3Yg6r631UGJK9pfXPIMaWGlAl xyUQhWWlgBvXcUSoDVWec1YElRBvaM4sOctVQ8xjZBsD+KfEJhtUeDIWUcVPcpPgzV zYZJkUZlJjRRTo2B9OpHAgiZ3e5mFOf2mhABP8nUsvajUV2shBACl6VLLFilTs5qpp ZmUylZSLjUvbg== Message-ID: <53862bd4-c991-a17f-eacb-25ab2aa1e7b0@collabora.com> Date: Tue, 6 Jun 2023 12:54:30 +0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Cc: Muhammad Usama Anjum , David Hildenbrand , Peter Xu , Shuah Khan , Nathan Chancellor , linux-mm@kvack.org, linux-kselftest@vger.kernel.org, LKML Subject: Re: [PATCH v3 06/11] selftests/mm: fix two -Wformat-security warnings in uffd builds Content-Language: en-US To: John Hubbard , Andrew Morton References: <20230606071637.267103-1-jhubbard@nvidia.com> <20230606071637.267103-7-jhubbard@nvidia.com> From: Muhammad Usama Anjum In-Reply-To: <20230606071637.267103-7-jhubbard@nvidia.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org On 6/6/23 12:16 PM, John Hubbard wrote: > The uffd tests generate two compile time warnings from clang's > -Wformat-security setting. These trigger at the call sites for > uffd_test_start() and uffd_test_skip(). > > 1) Fix the uffd_test_start() issue by removing the intermediate > test_name variable (thanks to David Hildenbrand for showing how to do > this). > > 2) Fix the uffd_test_skip() issue by observing that there is no need for > a macro and a variable args approach, because all callers of > uffd_test_skip() pass in a simple char* string, without any format > specifiers. So just change uffd_test_skip() into a regular C function. > > Reviewed-by: David Hildenbrand > Reviewed-by: Peter Xu > Signed-off-by: John Hubbard Tested-by: Muhammad Usama Anjum > --- > tools/testing/selftests/mm/uffd-unit-tests.c | 16 ++++++---------- > 1 file changed, 6 insertions(+), 10 deletions(-) > > 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(); > +} > > /* > * Returns 1 if specific userfaultfd supported, 0 otherwise. Note, we'll > @@ -1149,7 +1148,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 +1190,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; -- BR, Muhammad Usama Anjum