linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dax: fix potential overflow on 32bit machine
@ 2017-12-05  3:32 zhangyi (F)
  2017-12-05  5:24 ` Matthew Wilcox
  0 siblings, 1 reply; 7+ messages in thread
From: zhangyi (F) @ 2017-12-05  3:32 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: mawilcox, ross.zwisler, viro, yi.zhang, miaoxie

On 32bit machine, when mmap2 a large enough file with pgoff more than
ULONG_MAX >> PAGE_SHIFT, it will trigger offset overflow and lead to
unmap the wrong page in dax_insert_mapping_entry(). This patch cast
pgoff to 64bit to prevent the overflow.

Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
---
 fs/dax.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/dax.c b/fs/dax.c
index 78b72c4..8e12848 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -539,10 +539,11 @@ static void *dax_insert_mapping_entry(struct address_space *mapping,
 		/* we are replacing a zero page with block mapping */
 		if (dax_is_pmd_entry(entry))
 			unmap_mapping_range(mapping,
-					(vmf->pgoff << PAGE_SHIFT) & PMD_MASK,
+					((loff_t)vmf->pgoff << PAGE_SHIFT) & PMD_MASK,
 					PMD_SIZE, 0);
 		else /* pte entry */
-			unmap_mapping_range(mapping, vmf->pgoff << PAGE_SHIFT,
+			unmap_mapping_range(mapping,
+					(loff_t)vmf->pgoff << PAGE_SHIFT,
 					PAGE_SIZE, 0);
 	}
 
-- 
2.9.5

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

end of thread, other threads:[~2017-12-05 19:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-05  3:32 [PATCH] dax: fix potential overflow on 32bit machine zhangyi (F)
2017-12-05  5:24 ` Matthew Wilcox
2017-12-05  8:40   ` zhangyi (F)
2017-12-05 17:07   ` Ross Zwisler
2017-12-05 17:37     ` Matthew Wilcox
2017-12-05 19:19       ` Ross Zwisler
2017-12-05 19:54         ` Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).