Re: [PATCH] mm/filemap: Align last_index to folio size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 15 Jul 2025 00:34:12 +0200 Klara Modin <klarasmodin@xxxxxxxxx> 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.




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux