From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 613DE20356884 for ; Wed, 15 Nov 2017 11:12:30 -0800 (PST) Date: Wed, 15 Nov 2017 12:16:37 -0700 From: Ross Zwisler Subject: Re: [patch] dax: fix PMD faults on zero-length files Message-ID: <20171115191637.GA30208@linux.intel.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: Dan Williams Cc: linux-fsdevel , "Zwisler, Ross , linux-nvdimm@lists.01.org" List-ID: On Tue, Nov 14, 2017 at 05:47:51PM -0800, Dan Williams wrote: > On Tue, Nov 14, 2017 at 5:37 PM, Jeff Moyer wrote: > > PMD faults on a zero length file on a file system mounted with -o dax > > will not generate SIGBUS as expected. > > > > fd = open(...O_TRUNC); > > addr = mmap(NULL, 2*1024*1024, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); > > *addr = 'a'; > > > > > > The problem is this code in dax_iomap_pmd_fault: > > > > max_pgoff = (i_size_read(inode) - 1) >> PAGE_SHIFT; > > > > If the inode size is zero, we end up with a max_pgoff that is way larger > > than 0. :) Fix it by using DIV_ROUND_UP, as is done elsewhere in the > > kernel. > > > > I tested this with some simple test code that ensured that SIGBUS was > > received where expected. > > > > I assume this needs: > > Fixes: 642261ac995e ("dax: add struct iomap based DAX PMD support") > Cc: > > ...otherwise looks good to me. Yep, this fix looks good, thanks. You can add: Reviewed-by: Ross Zwisler _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm