linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "zhangyi (F)" <yi.zhang@huawei.com>
To: <linux-fsdevel@vger.kernel.org>
Cc: <mawilcox@microsoft.com>, <ross.zwisler@linux.intel.com>,
	<viro@zeniv.linux.org.uk>, <yi.zhang@huawei.com>,
	<miaoxie@huawei.com>
Subject: [PATCH] dax: fix potential overflow on 32bit machine
Date: Tue, 5 Dec 2017 11:32:10 +0800	[thread overview]
Message-ID: <20171205033210.38338-1-yi.zhang@huawei.com> (raw)

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

             reply	other threads:[~2017-12-05  3:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-05  3:32 zhangyi (F) [this message]
2017-12-05  5:24 ` [PATCH] dax: fix potential overflow on 32bit machine 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

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=20171205033210.38338-1-yi.zhang@huawei.com \
    --to=yi.zhang@huawei.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=mawilcox@microsoft.com \
    --cc=miaoxie@huawei.com \
    --cc=ross.zwisler@linux.intel.com \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).