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] [day] [month] [year] [list]
Message-ID: <797ec84e-7257-d97a-5c13-9a9d9f1f650a@c-s.fr>
Date:   Thu, 27 Feb 2020 18:03:20 +0100
From:   Christophe Leroy <christophe.leroy@....fr>
To:     Shuah Khan <shuah@...nel.org>
Cc:     Michael Ellerman <mpe@...erman.id.au>, linux-mm@...ck.org,
        linuxppc-dev@...ts.ozlabs.org, linux-kernel@...r.kernel.org,
        linux-kselftest@...r.kernel.org
Subject: Re: [PATCH] selftests/vm: Fix map_hugetlb length used for testing
 read and write

Shuah,

Le 06/02/2020 à 09:42, Christophe Leroy a écrit :
> Commit fa7b9a805c79 ("tools/selftest/vm: allow choosing mem size and
> page size in map_hugetlb") added the possibility to change the size
> of memory mapped for the test, but left the read and write test using
> the default value. This is unnoticed when mapping a length greater
> than the default one, but segfaults otherwise.
> 
> Fix read_bytes() and write_bytes() by giving them the real length.
> 
> Also fix the call to munmap().
> 
> Fixes: fa7b9a805c79 ("tools/selftest/vm: allow choosing mem size and page size in map_hugetlb")
> Cc: stable@...r.kernel.org

Can you also consider this one for next rc ?

Thanks
Christophe

> Signed-off-by: Christophe Leroy <christophe.leroy@....fr>
> ---
>   tools/testing/selftests/vm/map_hugetlb.c | 14 +++++++-------
>   1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/tools/testing/selftests/vm/map_hugetlb.c b/tools/testing/selftests/vm/map_hugetlb.c
> index 5a2d7b8efc40..6af951900aa3 100644
> --- a/tools/testing/selftests/vm/map_hugetlb.c
> +++ b/tools/testing/selftests/vm/map_hugetlb.c
> @@ -45,20 +45,20 @@ static void check_bytes(char *addr)
>   	printf("First hex is %x\n", *((unsigned int *)addr));
>   }
>   
> -static void write_bytes(char *addr)
> +static void write_bytes(char *addr, size_t length)
>   {
>   	unsigned long i;
>   
> -	for (i = 0; i < LENGTH; i++)
> +	for (i = 0; i < length; i++)
>   		*(addr + i) = (char)i;
>   }
>   
> -static int read_bytes(char *addr)
> +static int read_bytes(char *addr, size_t length)
>   {
>   	unsigned long i;
>   
>   	check_bytes(addr);
> -	for (i = 0; i < LENGTH; i++)
> +	for (i = 0; i < length; i++)
>   		if (*(addr + i) != (char)i) {
>   			printf("Mismatch at %lu\n", i);
>   			return 1;
> @@ -96,11 +96,11 @@ int main(int argc, char **argv)
>   
>   	printf("Returned address is %p\n", addr);
>   	check_bytes(addr);
> -	write_bytes(addr);
> -	ret = read_bytes(addr);
> +	write_bytes(addr, length);
> +	ret = read_bytes(addr, length);
>   
>   	/* munmap() length of MAP_HUGETLB memory must be hugepage aligned */
> -	if (munmap(addr, LENGTH)) {
> +	if (munmap(addr, length)) {
>   		perror("munmap");
>   		exit(1);
>   	}
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ