Jeff Moyer
c21261e631
dax: fix PMD faults on zero-length files
...
commit 957ac8c421ad8b5eef9b17fe98e146d8311a541e upstream.
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';
<expect SIGBUS>
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.
Fixes: 642261ac995e ("dax: add struct iomap based DAX PMD support")
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-30 08:40:53 +00:00
..
2017-11-30 08:40:49 +00:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-30 08:40:44 +00:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-30 08:40:45 +00:00
2017-11-02 11:10:55 +01:00
2017-11-02 10:04:46 -07:00
2017-11-02 10:04:46 -07:00
2017-11-24 08:37:05 +01:00
2017-11-02 11:10:55 +01:00
2017-11-30 08:40:44 +00:00
2017-08-24 13:23:03 -07:00
2017-11-02 11:10:55 +01:00
2017-11-30 08:40:45 +00:00
2017-11-02 11:10:55 +01:00
2017-09-07 11:59:42 -07:00
2017-11-02 11:10:55 +01:00
2017-11-30 08:40:48 +00:00
2017-11-30 08:40:45 +00:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-10-25 16:34:27 +02:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-03 07:39:19 -07:00
2017-11-30 08:40:45 +00:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-09-07 11:59:42 -07:00
2017-11-30 08:40:53 +00:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-30 08:40:46 +00:00
2017-11-30 08:40:46 +00:00
2017-11-30 08:40:44 +00:00
2017-11-02 11:10:55 +01:00
2017-11-30 08:40:47 +00:00
2017-11-02 11:10:55 +01:00
2017-11-24 08:37:04 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-30 08:40:43 +00:00
2017-11-03 07:39:19 -07:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-09-06 17:27:26 -07:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 10:04:46 -07:00
2017-09-14 19:29:55 -07:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-09-04 19:05:15 -04:00
2017-09-14 18:13:32 -07:00
2017-09-14 18:13:32 -07:00
2017-11-02 11:10:55 +01:00
2017-10-13 16:18:33 -07:00
2017-10-03 17:54:25 -07:00
2017-10-13 16:18:33 -07:00
2017-11-30 08:40:45 +00:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-30 08:40:53 +00:00
2017-10-18 14:51:50 -04:00
2017-11-02 11:10:55 +01:00
2017-09-08 18:26:49 -07:00
2017-10-19 22:13:40 -04:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-08-28 00:50:23 -04:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-09-13 09:11:44 -07:00
2017-09-13 09:11:44 -07:00
2017-11-02 11:10:55 +01:00
2017-10-16 12:11:56 -07:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-10-17 02:22:07 -04:00
2017-11-02 11:10:55 +01:00
2017-09-05 12:53:12 +02:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-09-04 19:05:15 -04:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-10-03 17:54:25 -07:00
2017-11-02 11:10:55 +01:00
2017-10-04 18:03:15 +11:00