Skip to content

Commit 1ef6ea0

Browse files
Mikulas Patockatorvalds
authored andcommitted
ext2: don't update mtime on COW faults
When running in a dax mode, if the user maps a page with MAP_PRIVATE and PROT_WRITE, the ext2 filesystem would incorrectly update ctime and mtime when the user hits a COW fault. This breaks building of the Linux kernel. How to reproduce: 1. extract the Linux kernel tree on dax-mounted ext2 filesystem 2. run make clean 3. run make -j12 4. run make -j12 at step 4, make would incorrectly rebuild the whole kernel (although it was already built in step 3). The reason for the breakage is that almost all object files depend on objtool. When we run objtool, it takes COW page fault on its .data section, and these faults will incorrectly update the timestamp of the objtool binary. The updated timestamp causes make to rebuild the whole tree. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Cc: stable@vger.kernel.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent c70672d commit 1ef6ea0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fs/ext2/file.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,10 @@ static vm_fault_t ext2_dax_fault(struct vm_fault *vmf)
9393
struct inode *inode = file_inode(vmf->vma->vm_file);
9494
struct ext2_inode_info *ei = EXT2_I(inode);
9595
vm_fault_t ret;
96+
bool write = (vmf->flags & FAULT_FLAG_WRITE) &&
97+
(vmf->vma->vm_flags & VM_SHARED);
9698

97-
if (vmf->flags & FAULT_FLAG_WRITE) {
99+
if (write) {
98100
sb_start_pagefault(inode->i_sb);
99101
file_update_time(vmf->vma->vm_file);
100102
}
@@ -103,7 +105,7 @@ static vm_fault_t ext2_dax_fault(struct vm_fault *vmf)
103105
ret = dax_iomap_fault(vmf, PE_SIZE_PTE, NULL, NULL, &ext2_iomap_ops);
104106

105107
up_read(&ei->dax_sem);
106-
if (vmf->flags & FAULT_FLAG_WRITE)
108+
if (write)
107109
sb_end_pagefault(inode->i_sb);
108110
return ret;
109111
}

0 commit comments

Comments
 (0)