diff options
| author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2026-04-18 10:45:02 +0200 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2026-04-18 10:45:02 +0200 |
| commit | 6e93ccc29258103e1fc652464b4ff75bc022da73 (patch) | |
| tree | 85f741fa600ee0745b818a8c9cfdfc9b5b824c86 /mm/filemap.c | |
| parent | 327d73d5ef3ac25ffb58648c2c588c897b7efc41 (diff) | |
| parent | 47a33eea6d5145d53e42315381ef28286c2218fb (diff) | |
Merge v6.18.23linux-rolling-lts
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'mm/filemap.c')
| -rw-r--r-- | mm/filemap.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/mm/filemap.c b/mm/filemap.c index 8a7f4ce69aff0..91dcfe14a67b7 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3823,14 +3823,19 @@ vm_fault_t filemap_map_pages(struct vm_fault *vmf, unsigned int nr_pages = 0, folio_type; unsigned short mmap_miss = 0, mmap_miss_saved; + /* + * Recalculate end_pgoff based on file_end before calling + * next_uptodate_folio() to avoid races with concurrent + * truncation. + */ + file_end = DIV_ROUND_UP(i_size_read(mapping->host), PAGE_SIZE) - 1; + end_pgoff = min(end_pgoff, file_end); + rcu_read_lock(); folio = next_uptodate_folio(&xas, mapping, end_pgoff); if (!folio) goto out; - file_end = DIV_ROUND_UP(i_size_read(mapping->host), PAGE_SIZE) - 1; - end_pgoff = min(end_pgoff, file_end); - /* * Do not allow to map with PMD across i_size to preserve * SIGBUS semantics. |
