lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 2 Jun 2023 14:22:04 -0700
From:   John Hubbard <jhubbard@...dia.com>
To:     David Hildenbrand <david@...hat.com>,
        Andrew Morton <akpm@...ux-foundation.org>
CC:     Peter Xu <peterx@...hat.com>, Shuah Khan <shuah@...nel.org>,
        "Nathan Chancellor" <nathan@...nel.org>, <linux-mm@...ck.org>,
        <linux-kselftest@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 07/12] selftests/mm: set -Wno-format-security to avoid
 uffd build warnings

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,
-- 
John Hubbard
NVIDIA

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ