From: Andrew Morton <akpm@linux-foundation.org>
To: Klara Modin <klarasmodin@gmail.com>
Cc: Youling Tang <youling.tang@linux.dev>,
Matthew Wilcox <willy@infradead.org>, Jan Kara <jack@suse.cz>,
linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, chizhiling@163.com,
Youling Tang <tangyouling@kylinos.cn>,
Chi Zhiling <chizhiling@kylinos.cn>
Subject: Re: [PATCH] mm/filemap: Align last_index to folio size
Date: Mon, 14 Jul 2025 15:43:55 -0700 [thread overview]
Message-ID: <20250714154355.e27c812d71b5968bdd83764c@linux-foundation.org> (raw)
In-Reply-To: <yru7qf5gvyzccq5ohhpylvxug5lr5tf54omspbjh4sm6pcdb2r@fpjgj2pxw7va>
On Tue, 15 Jul 2025 00:34:12 +0200 Klara Modin <klarasmodin@gmail.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.
next prev parent reply other threads:[~2025-07-14 22:44 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-11 5:55 Youling Tang
2025-07-11 16:08 ` David Hildenbrand
2025-07-14 8:16 ` Ryan Roberts
2025-07-14 9:33 ` Jan Kara
2025-08-12 9:08 ` Youling Tang
2025-09-03 22:50 ` Andrew Morton
2025-09-04 2:04 ` Youling Tang
2025-09-05 12:50 ` Jan Kara
2025-09-09 6:15 ` Youling Tang
2025-09-09 6:41 ` Andrew Morton
2025-07-14 22:34 ` Klara Modin
2025-07-14 22:43 ` Andrew Morton [this message]
2025-07-14 22:48 ` Klara Modin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250714154355.e27c812d71b5968bdd83764c@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=chizhiling@163.com \
--cc=chizhiling@kylinos.cn \
--cc=jack@suse.cz \
--cc=klarasmodin@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=tangyouling@kylinos.cn \
--cc=willy@infradead.org \
--cc=youling.tang@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox