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: <42ba379f-baaa-4803-8ebe-f7ddeab87522@oracle.com>
Date: Thu, 31 Jul 2025 12:39:36 -0400
From: Sidhartha Kumar <sidhartha.kumar@...cle.com>
To: Muhammad Usama Anjum <usama.anjum@...labora.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        David Hildenbrand <david@...hat.com>,
        Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
        "Liam R. Howlett" <Liam.Howlett@...cle.com>,
        Vlastimil Babka
 <vbabka@...e.cz>, Mike Rapoport <rppt@...nel.org>,
        Suren Baghdasaryan <surenb@...gle.com>, Michal Hocko <mhocko@...e.com>,
        Jason Gunthorpe <jgg@...pe.ca>, John Hubbard <jhubbard@...dia.com>,
        Peter Xu <peterx@...hat.com>, Leon Romanovsky <leon@...nel.org>,
        Zi Yan <ziy@...dia.com>, Baolin Wang <baolin.wang@...ux.alibaba.com>,
        Nico Pache <npache@...hat.com>, Ryan Roberts <ryan.roberts@....com>,
        Dev Jain <dev.jain@....com>, Barry Song <baohua@...nel.org>,
        Paul Walmsley <paul.walmsley@...ive.com>,
        Palmer Dabbelt
 <palmer@...belt.com>,
        Albert Ou <aou@...s.berkeley.edu>, Alexandre Ghiti <alex@...ti.fr>,
        linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-mm@...ck.org, linux-riscv@...ts.infradead.org,
        Shuah Khan <shuah@...nel.org>
Cc: kernel@...labora.com
Subject: Re: [PATCH v2 2/8] selftests/mm: protection_keys: Fix dead code

On 7/31/25 12:01 PM, Muhammad Usama Anjum wrote:
> The while loop doesn't execute and following warning gets generated:
> 
> protection_keys.c:561:15: warning: code will never be executed
> [-Wunreachable-code]
>                  int rpkey = alloc_random_pkey();
> 
> Let's enable the while loop such that it gets executed nr_iterations
> times. Simplify the code a bit as well.
> 
> Signed-off-by: Muhammad Usama Anjum <usama.anjum@...labora.com>

Reviewed-by: Sidhartha Kumar <sidhartha.kumar@...cle.com>

> ---
>   tools/testing/selftests/mm/protection_keys.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/tools/testing/selftests/mm/protection_keys.c b/tools/testing/selftests/mm/protection_keys.c
> index 23ebec367015f..6281d4c61b50e 100644
> --- a/tools/testing/selftests/mm/protection_keys.c
> +++ b/tools/testing/selftests/mm/protection_keys.c
> @@ -557,13 +557,11 @@ int mprotect_pkey(void *ptr, size_t size, unsigned long orig_prot,
>   	int nr_iterations = random() % 100;
>   	int ret;
>   
> -	while (0) {
> +	while (nr_iterations-- >= 0) {
>   		int rpkey = alloc_random_pkey();
>   		ret = sys_mprotect_pkey(ptr, size, orig_prot, pkey);
>   		dprintf1("sys_mprotect_pkey(%p, %zx, prot=0x%lx, pkey=%ld) ret: %d\n",
>   				ptr, size, orig_prot, pkey, ret);
> -		if (nr_iterations-- < 0)
> -			break;
>   
>   		dprintf1("%s()::%d, ret: %d pkey_reg: 0x%016llx"
>   			" shadow: 0x%016llx\n",


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ