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]
Message-ID: <cf3c237e-69c8-dd6e-26fc-fe19de910813@redhat.com>
Date:   Thu, 13 Jul 2023 15:56:52 +0200
From:   David Hildenbrand <david@...hat.com>
To:     Ryan Roberts <ryan.roberts@....com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Shuah Khan <shuah@...nel.org>,
        Jérôme Glisse <jglisse@...hat.com>,
        Mark Brown <broonie@...nel.org>,
        John Hubbard <jhubbard@...dia.com>,
        Florent Revest <revest@...omium.org>,
        "Liam R. Howlett" <Liam.Howlett@...cle.com>
Cc:     linux-kernel@...r.kernel.org, linux-mm@...ck.org,
        linux-kselftest@...r.kernel.org
Subject: Re: [PATCH v1 3/9] selftests/mm: Skip soft-dirty tests on arm64

On 13.07.23 15:54, Ryan Roberts wrote:
> arm64 does not support the soft-dirty PTE bit. However there are tests
> in `madv_populate` and `soft-dirty` which assume it is supported and
> cause spurious failures to be reported when preferred behaviour would be
> to mark the tests as skipped.
> 
> Unfortunately, the only way to determine if the soft-dirty dirty bit is
> supported is to write to a page, then see if the bit is set in
> /proc/self/pagemap. But the tests that we want to conditionally execute
> are testing precicesly this. So if we introduced this feature check, we
> could accedentally turn a real failure (on a system that claims to
> support soft-dirty) into a skip.
> 
> So instead, do the check based on architecture; for arm64, we report
> that soft-dirty is not supported. This is wrapped up into a utility
> function `system_has_softdirty()`, which is used to skip the whole
> `soft-dirty` suite, and mark the soft-dirty tests in the `madv_populate`
> suite as skipped.
> 
> Signed-off-by: Ryan Roberts <ryan.roberts@....com>
> ---
>   tools/testing/selftests/mm/madv_populate.c | 18 +++++++++++++-----
>   tools/testing/selftests/mm/soft-dirty.c    |  3 +++
>   tools/testing/selftests/mm/vm_util.c       | 17 +++++++++++++++++
>   tools/testing/selftests/mm/vm_util.h       |  1 +
>   4 files changed, 34 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/testing/selftests/mm/madv_populate.c b/tools/testing/selftests/mm/madv_populate.c
> index 60547245e479..5a8c176d7fec 100644
> --- a/tools/testing/selftests/mm/madv_populate.c
> +++ b/tools/testing/selftests/mm/madv_populate.c
> @@ -232,6 +232,14 @@ static bool range_is_not_softdirty(char *start, ssize_t size)
>   	return ret;
>   }
> 
> +#define ksft_test_result_if_softdirty(cond, ...)	\
> +do {							\
> +	if (system_has_softdirty())			\
> +		ksft_test_result(cond, __VA_ARGS__);	\
> +	else						\
> +		ksft_test_result_skip(__VA_ARGS__);	\
> +} while (0)
> +
>   static void test_softdirty(void)
>   {
>   	char *addr;
> @@ -246,19 +254,19 @@ static void test_softdirty(void)
> 
>   	/* Clear any softdirty bits. */
>   	clear_softdirty();
> -	ksft_test_result(range_is_not_softdirty(addr, SIZE),
> +	ksft_test_result_if_softdirty(range_is_not_softdirty(addr, SIZE),
>   			 "range is not softdirty\n");
> 
>   	/* Populating READ should set softdirty. */
>   	ret = madvise(addr, SIZE, MADV_POPULATE_READ);
> -	ksft_test_result(!ret, "MADV_POPULATE_READ\n");
> -	ksft_test_result(range_is_not_softdirty(addr, SIZE),
> +	ksft_test_result_if_softdirty(!ret, "MADV_POPULATE_READ\n");
> +	ksft_test_result_if_softdirty(range_is_not_softdirty(addr, SIZE),
>   			 "range is not softdirty\n");
> 
>   	/* Populating WRITE should set softdirty. */
>   	ret = madvise(addr, SIZE, MADV_POPULATE_WRITE);
> -	ksft_test_result(!ret, "MADV_POPULATE_WRITE\n");
> -	ksft_test_result(range_is_softdirty(addr, SIZE),
> +	ksft_test_result_if_softdirty(!ret, "MADV_POPULATE_WRITE\n");
> +	ksft_test_result_if_softdirty(range_is_softdirty(addr, SIZE),
>   			 "range is softdirty\n");

We probably want to skip the whole test_*softdirty* test instead of 
adding this (IMHO suboptimal) ksft_test_result_if_softdirty.

-- 
Cheers,

David / dhildenb

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ