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: <qbuhdfdvbyida5y7g34o4rf5s5ntx462ffy3wso3pb5f3t4pev@3hqnswkp7of6>
Date: Thu, 5 Jun 2025 10:22:23 +0200
From: Jan Kara <jack@...e.cz>
To: Chi Zhiling <chizhiling@....com>
Cc: willy@...radead.org, akpm@...ux-foundation.org, josef@...icpanda.com, 
	jack@...e.cz, linux-fsdevel@...r.kernel.org, linux-mm@...ck.org, 
	linux-kernel@...r.kernel.org, Chi Zhiling <chizhiling@...inos.cn>
Subject: Re: [PATCH] readahead: fix return value of page_cache_next_miss()
 when no hole is found

On Thu 05-06-25 13:49:35, Chi Zhiling wrote:
> From: Chi Zhiling <chizhiling@...inos.cn>
> 
> max_scan in page_cache_next_miss always decreases to zero when no hole
> is found, causing the return value to be index + 0.
> 
> Fix this by preserving the max_scan value throughout the loop.
> 
> Fixes: 901a269ff3d5 ("filemap: fix page_cache_next_miss() when no hole found")
> Signed-off-by: Chi Zhiling <chizhiling@...inos.cn>

Indeed. Thanks for catching this. Don't know how I missed that. Feel free
to add:

Reviewed-by: Jan Kara <jack@...e.cz>

								Honza

> ---
>  mm/filemap.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/filemap.c b/mm/filemap.c
> index b5e784f34d98..148be65be1cd 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -1767,8 +1767,9 @@ pgoff_t page_cache_next_miss(struct address_space *mapping,
>  			     pgoff_t index, unsigned long max_scan)
>  {
>  	XA_STATE(xas, &mapping->i_pages, index);
> +	unsigned long nr = max_scan;
>  
> -	while (max_scan--) {
> +	while (nr--) {
>  		void *entry = xas_next(&xas);
>  		if (!entry || xa_is_value(entry))
>  			return xas.xa_index;
> -- 
> 2.43.0
> 
-- 
Jan Kara <jack@...e.com>
SUSE Labs, CR

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ