linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] filemap: avoid truncating 64-bit offset to 32 bits
@ 2025-01-02 19:04 Marco Nelissen
  2025-01-02 22:10 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Marco Nelissen @ 2025-01-02 19:04 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle),
	Andrew Morton, linux-fsdevel, linux-mm, linux-kernel, linux-xfs
  Cc: Marco Nelissen

on 32-bit kernels, folio_seek_hole_data() was inadvertently truncating a
64-bit value to 32 bits, leading to a possible infinite loop when writing
to an xfs filesystem.

Signed-off-by: Marco Nelissen <marco.nelissen@gmail.com>
---
 mm/filemap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/filemap.c b/mm/filemap.c
index f61cf51c2238..f5c93683dbcf 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -3005,7 +3005,7 @@ static inline loff_t folio_seek_hole_data(struct xa_state *xas,
 		if (ops->is_partially_uptodate(folio, offset, bsz) ==
 							seek_data)
 			break;
-		start = (start + bsz) & ~(bsz - 1);
+		start = (start + bsz) & ~((u64)bsz - 1);
 		offset += bsz;
 	} while (offset < folio_size(folio));
 unlock:
-- 
2.39.5



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-01-02 23:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-02 19:04 [PATCH] filemap: avoid truncating 64-bit offset to 32 bits Marco Nelissen
2025-01-02 22:10 ` Andrew Morton
2025-01-02 23:25   ` Darrick J. Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox