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: <20250714154355.e27c812d71b5968bdd83764c@linux-foundation.org>
Date: Mon, 14 Jul 2025 15:43:55 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Klara Modin <klarasmodin@...il.com>
Cc: Youling Tang <youling.tang@...ux.dev>, Matthew Wilcox
 <willy@...radead.org>, Jan Kara <jack@...e.cz>,
 linux-fsdevel@...r.kernel.org, linux-mm@...ck.org,
 linux-kernel@...r.kernel.org, chizhiling@....com, Youling Tang
 <tangyouling@...inos.cn>, Chi Zhiling <chizhiling@...inos.cn>
Subject: Re: [PATCH] mm/filemap: Align last_index to folio size

On Tue, 15 Jul 2025 00:34:12 +0200 Klara Modin <klarasmodin@...il.com> wrote:

> iocb->ki_pos is loff_t (long long) while pgoff_t is unsigned long and
> this overflow seems to happen in practice, resulting in last_index being
> before index.
> 
> The following diff resolves the issue for me:
> 
> diff --git a/mm/filemap.c b/mm/filemap.c
> index 3c071307f40e..d2902be0b845 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -2585,8 +2585,8 @@ static int filemap_get_pages(struct kiocb *iocb, size_t count,
>  	int err = 0;
>  
>  	/* "last_index" is the index of the folio beyond the end of the read */
> -	last_index = round_up(iocb->ki_pos + count, mapping_min_folio_nrbytes(mapping));
> -	last_index >>= PAGE_SHIFT;
> +	last_index = round_up(iocb->ki_pos + count,
> +			mapping_min_folio_nrbytes(mapping)) >> PAGE_SHIFT;
>  retry:
>  	if (fatal_signal_pending(current))
>  		return -EINTR;

Looks good, thanks.  I added your signed-off-by (which I trust is OK?)
and queued this up.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ