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: <4c709253-50de-45ee-9cbf-8bed65eff857@linuxfoundation.org>
Date: Fri, 9 Aug 2024 11:20:48 -0600
From: Shuah Khan <skhan@...uxfoundation.org>
To: Dan Carpenter <dan.carpenter@...aro.org>, Dev Jain <dev.jain@....com>
Cc: Andrew Morton <akpm@...ux-foundation.org>, Shuah Khan <shuah@...nel.org>,
 linux-mm@...ck.org, linux-kselftest@...r.kernel.org,
 linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
 Shuah Khan <skhan@...uxfoundation.org>
Subject: Re: [PATCH] selftests/mm: compaction_test: Fix off by one in
 check_compaction()

On 8/9/24 06:32, Dan Carpenter wrote:
> The "initial_nr_hugepages" variable is unsigned long so it takes up to
> 20 characters to print, plus 1 more character for the NUL terminator.
> Unfortunately, this buffer is not quite large enough for the terminator
> to fit.  Also use snprintf() for a belt and suspenders approach.
> 
> Fixes: fb9293b6b015 ("selftests/mm: compaction_test: fix bogus test success and reduce probability of OOM-killer invocation")
> Signed-off-by: Dan Carpenter <dan.carpenter@...aro.org>
> ---
>   tools/testing/selftests/mm/compaction_test.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/mm/compaction_test.c b/tools/testing/selftests/mm/compaction_test.c
> index e140558e6f53..2c3a0eb6b22d 100644
> --- a/tools/testing/selftests/mm/compaction_test.c
> +++ b/tools/testing/selftests/mm/compaction_test.c
> @@ -89,9 +89,10 @@ int check_compaction(unsigned long mem_free, unsigned long hugepage_size,
>   	int fd, ret = -1;
>   	int compaction_index = 0;
>   	char nr_hugepages[20] = {0};
> -	char init_nr_hugepages[20] = {0};
> +	char init_nr_hugepages[24] = {0};

Can we exceed this limit too? Can you make this a define?

>   
> -	sprintf(init_nr_hugepages, "%lu", initial_nr_hugepages);
> +	snprintf(init_nr_hugepages, sizeof(init_nr_hugepages),
> +		 "%lu", initial_nr_hugepages);
>   
>   	/* We want to test with 80% of available memory. Else, OOM killer comes
>   	   in to play */

With that change:

Reviewed-by: Shuah Khan <skhan@...uxfoundation.org>

thanks,
-- Shuah

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ