aufs: Update support patches to aufs4.x-rcN-20150921

mmap: Fix races in madvise_remove() and sys_msync() (Closes: #796036)
This commit is contained in:
Ben Hutchings 2015-09-19 03:20:55 +02:00
parent 5932de869a
commit 4cfa583b64
4 changed files with 76 additions and 81 deletions

2
debian/changelog vendored
View File

@ -13,6 +13,8 @@ linux (4.2-1~exp2) UNRELEASED; urgency=medium
callers
- dcache: Handle escaped paths in prepend_path
- vfs: Test for and handle paths that are unreachable from their mnt_root
* aufs: Update support patches to aufs4.x-rcN-20150921
- mmap: Fix races in madvise_remove() and sys_msync() (Closes: #796036)
[ Aurelien Jarno ]
* [mips*el] Fix BPF assembly code for pre-R2 CPUs. (fixes FTBFS)

View File

@ -1,7 +1,7 @@
From: J. R. Okajima <hooanon05@yahoo.co.jp>
Date: Sat Jun 6 21:25:05 2015 +0900
Date: Sat Sep 19 06:24:59 2015 +0900
Subject: aufs4.x-rcN base patch
Origin: https://github.com/sfjro/aufs4-standalone/tree/aa65d099b5220918a0509c91ece96b79f7cb4b2d
Origin: https://github.com/sfjro/aufs4-standalone/tree/4e2f15c8b322d41405616d118f13fe2c4abbf26f
Bug-Debian: https://bugs.debian.org/541828
Patch headers added by debian/patches/features/all/aufs4/gen-patch
@ -9,10 +9,10 @@ Patch headers added by debian/patches/features/all/aufs4/gen-patch
aufs4.x-rcN base patch
diff --git a/MAINTAINERS b/MAINTAINERS
index af802b3..b29cdd2 100644
index 8133cef..04beb19 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1880,6 +1880,19 @@ F: include/linux/audit.h
@@ -1939,6 +1939,19 @@ F: include/linux/audit.h
F: include/uapi/linux/audit.h
F: kernel/audit*
@ -33,10 +33,10 @@ index af802b3..b29cdd2 100644
M: Miguel Ojeda Sandonis <miguel.ojeda.sandonis@gmail.com>
W: http://miguelojeda.es/auxdisplay.htm
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index d7173cb..0160952 100644
index f7a4c9d..23103ad 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -540,6 +540,24 @@ static inline int is_loop_device(struct file *file)
@@ -560,6 +560,24 @@ static inline int is_loop_device(struct file *file)
return i && S_ISBLK(i->i_mode) && MAJOR(i->i_rdev) == LOOP_MAJOR;
}
@ -62,7 +62,7 @@ index d7173cb..0160952 100644
static ssize_t loop_attr_show(struct device *dev, char *page,
diff --git a/fs/dcache.c b/fs/dcache.c
index 37b5afd..bc261e2 100644
index 7a3f3e5..0b40298 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1164,7 +1164,7 @@ enum d_walk_ret {
@ -108,10 +108,10 @@ index 819ef3f..fd0414e 100644
{
mm_segment_t old_fs;
diff --git a/fs/splice.c b/fs/splice.c
index bfe62ae..fa5eee5 100644
index 5fc1e50..5f8385a 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -1101,8 +1101,8 @@ EXPORT_SYMBOL(generic_splice_sendpage);
@@ -1102,8 +1102,8 @@ EXPORT_SYMBOL(generic_splice_sendpage);
/*
* Attempt to initiate a splice from pipe to file.
*/
@ -122,7 +122,7 @@ index bfe62ae..fa5eee5 100644
{
ssize_t (*splice_write)(struct pipe_inode_info *, struct file *,
loff_t *, size_t, unsigned int);
@@ -1118,9 +1118,9 @@ static long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
@@ -1119,9 +1119,9 @@ static long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
/*
* Attempt to initiate a splice from a file to a pipe.
*/
@ -148,10 +148,10 @@ index f87d308..9a290b3 100644
static inline void fput_light(struct file *file, int fput_needed)
{
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 35ec87e..3229f97 100644
index a0653e5..86080ea 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1649,6 +1649,12 @@ ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector,
@@ -1661,6 +1661,12 @@ ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector,
struct iovec *fast_pointer,
struct iovec **ret_pointer);

View File

@ -1,18 +1,18 @@
From: J. R. Okajima <hooanon05@yahoo.co.jp>
Date: Sat May 2 13:25:44 2015 +0900
Date: Sat Sep 19 06:24:59 2015 +0900
Subject: aufs4.x-rcN mmap patch
Origin: https://github.com/sfjro/aufs4-standalone/tree/aa65d099b5220918a0509c91ece96b79f7cb4b2d
Origin: https://github.com/sfjro/aufs4-standalone/tree/4e2f15c8b322d41405616d118f13fe2c4abbf26f
Bug-Debian: https://bugs.debian.org/541828
Patch headers added by debian/patches/features/all/aufs4/gen-patch
aufs4.x-rcN mmap patch
[bwh: Adjusted context for 4.2]
diff --git a/fs/buffer.c b/fs/buffer.c
index 1cf7a53..076aff86 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -2473,7 +2473,7 @@ int block_page_mkwrite(struct vm_area_st
@@ -2473,7 +2473,7 @@ int block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf,
* Update file times before taking page lock. We may end up failing the
* fault so this update may be superfluous but who really cares...
*/
@ -21,9 +21,11 @@ aufs4.x-rcN mmap patch
ret = __block_page_mkwrite(vma, vmf, get_block);
sb_end_pagefault(sb);
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 87782e8..b287e64 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1939,7 +1939,7 @@ static int proc_map_files_get_link(struc
@@ -1934,7 +1934,7 @@ static int proc_map_files_get_link(struct dentry *dentry, struct path *path)
down_read(&mm->mmap_sem);
vma = find_exact_vma(mm, vm_start, vm_end);
if (vma && vma->vm_file) {
@ -32,9 +34,11 @@ aufs4.x-rcN mmap patch
path_get(path);
rc = 0;
}
diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
index f8595e8..cb8eda0 100644
--- a/fs/proc/nommu.c
+++ b/fs/proc/nommu.c
@@ -45,7 +45,10 @@ static int nommu_region_show(struct seq_
@@ -45,7 +45,10 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
file = region->vm_file;
if (file) {
@ -46,9 +50,11 @@ aufs4.x-rcN mmap patch
dev = inode->i_sb->s_dev;
ino = inode->i_ino;
}
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index ca1e091..8940e47 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -279,7 +279,10 @@ show_map_vma(struct seq_file *m, struct
@@ -279,7 +279,10 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
const char *name = NULL;
if (file) {
@ -60,7 +66,7 @@ aufs4.x-rcN mmap patch
dev = inode->i_sb->s_dev;
ino = inode->i_ino;
pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
@@ -1479,7 +1482,7 @@ static int show_numa_map(struct seq_file
@@ -1479,7 +1482,7 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
struct proc_maps_private *proc_priv = &numa_priv->proc_maps;
struct vm_area_struct *vma = v;
struct numa_maps *md = &numa_priv->md;
@ -69,27 +75,30 @@ aufs4.x-rcN mmap patch
struct mm_struct *mm = vma->vm_mm;
struct mm_walk walk = {
.hugetlb_entry = gather_hugetlb_stats,
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
index e0d64c9..7aa92db 100644
--- a/fs/proc/task_nommu.c
+++ b/fs/proc/task_nommu.c
@@ -160,7 +160,10 @@ static int nommu_vma_show(struct seq_fil
@@ -160,7 +160,10 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
file = vma->vm_file;
if (file) {
- struct inode *inode = file_inode(vma->vm_file);
+ struct inode *inode;
+
+ file = vma_pr_or_file(file);
+ file = vma_pr_or_file(vma);
+ inode = file_inode(file);
dev = inode->i_sb->s_dev;
ino = inode->i_ino;
pgoff = (loff_t)vma->vm_pgoff << PAGE_SHIFT;
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 2e872f9..2494ed2 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1173,6 +1173,28 @@ static inline int fixup_user_fault(struc
@@ -1173,6 +1173,28 @@ static inline int fixup_user_fault(struct task_struct *tsk,
}
#endif
+#ifdef CONFIG_MMU
+extern void vma_do_file_update_time(struct vm_area_struct *, const char[], int);
+extern struct file *vma_do_pr_or_file(struct vm_area_struct *, const char[],
+ int);
@ -102,18 +111,21 @@ aufs4.x-rcN mmap patch
+ __LINE__)
+#define vma_get_file(vma) vma_do_get_file(vma, __func__, __LINE__)
+#define vma_fput(vma) vma_do_fput(vma, __func__, __LINE__)
+#else
+
+#ifndef CONFIG_MMU
+extern struct file *vmr_do_pr_or_file(struct vm_region *, const char[], int);
+extern void vmr_do_fput(struct vm_region *, const char[], int);
+
+#define vmr_pr_or_file(region) vmr_do_pr_or_file(region, __func__, \
+ __LINE__)
+#define vmr_fput(region) vmr_do_fput(region, __func__, __LINE__)
+#endif /* CONFIG_MMU */
+#endif /* !CONFIG_MMU */
+
extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
void *buf, int len, int write);
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 0038ac7..409940d 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -259,6 +259,7 @@ struct vm_region {
@ -132,9 +144,11 @@ aufs4.x-rcN mmap patch
void * vm_private_data; /* was vm_pte (shared mem) */
#ifndef CONFIG_MMU
diff --git a/kernel/fork.c b/kernel/fork.c
index 1bfefc6..a86bd7f 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -461,7 +461,7 @@ static int dup_mmap(struct mm_struct *mm
@@ -456,7 +456,7 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
struct inode *inode = file_inode(file);
struct address_space *mapping = file->f_mapping;
@ -143,9 +157,11 @@ aufs4.x-rcN mmap patch
if (tmp->vm_flags & VM_DENYWRITE)
atomic_dec(&inode->i_writecount);
i_mmap_lock_write(mapping);
diff --git a/mm/Makefile b/mm/Makefile
index 98c4eae..3f0c9b9 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -21,7 +21,7 @@ obj-y := filemap.o mempool.o oom_kill.
@@ -21,7 +21,7 @@ obj-y := filemap.o mempool.o oom_kill.o \
mm_init.o mmu_context.o percpu.o slab_common.o \
compaction.o vmacache.o \
interval_tree.o list_lru.o workingset.o \
@ -154,9 +170,11 @@ aufs4.x-rcN mmap patch
obj-y += init-mm.o
diff --git a/mm/filemap.c b/mm/filemap.c
index 1283fc8..128f18f 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2089,7 +2089,7 @@ int filemap_page_mkwrite(struct vm_area_
@@ -2089,7 +2089,7 @@ int filemap_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
int ret = VM_FAULT_LOCKED;
sb_start_pagefault(inode->i_sb);
@ -165,26 +183,11 @@ aufs4.x-rcN mmap patch
lock_page(page);
if (page->mapping != inode->i_mapping) {
unlock_page(page);
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -321,12 +321,12 @@ static long madvise_remove(struct vm_are
* vma's reference to the file) can go away as soon as we drop
* mmap_sem.
*/
- get_file(f);
+ vma_get_file(vma);
up_read(&current->mm->mmap_sem);
error = vfs_fallocate(f,
FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
offset, end - start);
- fput(f);
+ vma_fput(vma);
down_read(&current->mm->mmap_sem);
return error;
}
diff --git a/mm/memory.c b/mm/memory.c
index a84fbb7..13973d2 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2034,7 +2034,7 @@ static inline int wp_page_reuse(struct m
@@ -2034,7 +2034,7 @@ static inline int wp_page_reuse(struct mm_struct *mm,
}
if (!page_mkwrite)
@ -193,9 +196,11 @@ aufs4.x-rcN mmap patch
}
return VM_FAULT_WRITE;
diff --git a/mm/mmap.c b/mm/mmap.c
index aa632ad..3ff75d3 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -274,7 +274,7 @@ static struct vm_area_struct *remove_vma
@@ -274,7 +274,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
if (vma->vm_ops && vma->vm_ops->close)
vma->vm_ops->close(vma);
if (vma->vm_file)
@ -204,7 +209,7 @@ aufs4.x-rcN mmap patch
mpol_put(vma_policy(vma));
kmem_cache_free(vm_area_cachep, vma);
return next;
@@ -886,7 +886,7 @@ again: remove_next = 1 + (end > next->
@@ -886,7 +886,7 @@ again: remove_next = 1 + (end > next->vm_end);
if (remove_next) {
if (file) {
uprobe_munmap(next, next->vm_start, next->vm_end);
@ -223,7 +228,7 @@ aufs4.x-rcN mmap patch
/* Undo any partial mapping done by a device driver. */
unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
@@ -2473,7 +2473,7 @@ static int __split_vma(struct mm_struct
@@ -2473,7 +2473,7 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
goto out_free_mpol;
if (new->vm_file)
@ -232,7 +237,7 @@ aufs4.x-rcN mmap patch
if (new->vm_ops && new->vm_ops->open)
new->vm_ops->open(new);
@@ -2492,7 +2492,7 @@ static int __split_vma(struct mm_struct
@@ -2492,7 +2492,7 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
if (new->vm_ops && new->vm_ops->close)
new->vm_ops->close(new);
if (new->vm_file)
@ -241,7 +246,7 @@ aufs4.x-rcN mmap patch
unlink_anon_vmas(new);
out_free_mpol:
mpol_put(vma_policy(new));
@@ -2635,7 +2635,6 @@ SYSCALL_DEFINE5(remap_file_pages, unsign
@@ -2635,7 +2635,6 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
struct vm_area_struct *vma;
unsigned long populate = 0;
unsigned long ret = -EINVAL;
@ -249,7 +254,7 @@ aufs4.x-rcN mmap patch
pr_warn_once("%s (%d) uses deprecated remap_file_pages() syscall. "
"See Documentation/vm/remap_file_pages.txt.\n",
@@ -2679,10 +2678,10 @@ SYSCALL_DEFINE5(remap_file_pages, unsign
@@ -2679,10 +2678,10 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
munlock_vma_pages_range(vma, start, start + size);
}
@ -262,7 +267,7 @@ aufs4.x-rcN mmap patch
out:
up_write(&mm->mmap_sem);
if (populate)
@@ -2949,7 +2948,7 @@ struct vm_area_struct *copy_vma(struct v
@@ -2949,7 +2948,7 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
if (anon_vma_clone(new_vma, vma))
goto out_free_mempol;
if (new_vma->vm_file)
@ -271,24 +276,11 @@ aufs4.x-rcN mmap patch
if (new_vma->vm_ops && new_vma->vm_ops->open)
new_vma->vm_ops->open(new_vma);
vma_link(mm, new_vma, prev, rb_link, rb_parent);
--- a/mm/msync.c
+++ b/mm/msync.c
@@ -84,10 +84,10 @@ SYSCALL_DEFINE3(msync, unsigned long, st
start = vma->vm_end;
if ((flags & MS_SYNC) && file &&
(vma->vm_flags & VM_SHARED)) {
- get_file(file);
+ vma_get_file(vma);
up_read(&mm->mmap_sem);
error = vfs_fsync_range(file, fstart, fend, 1);
- fput(file);
+ vma_fput(vma);
if (error || start >= end)
goto out;
down_read(&mm->mmap_sem);
diff --git a/mm/nommu.c b/mm/nommu.c
index 58ea364..f937b7e 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -671,7 +671,7 @@ static void __put_nommu_region(struct vm
@@ -671,7 +671,7 @@ static void __put_nommu_region(struct vm_region *region)
up_write(&nommu_region_sem);
if (region->vm_file)
@ -297,7 +289,7 @@ aufs4.x-rcN mmap patch
/* IO memory and memory shared directly out of the pagecache
* from ramfs/tmpfs mustn't be released here */
@@ -829,7 +829,7 @@ static void delete_vma(struct mm_struct
@@ -829,7 +829,7 @@ static void delete_vma(struct mm_struct *mm, struct vm_area_struct *vma)
if (vma->vm_ops && vma->vm_ops->close)
vma->vm_ops->close(vma);
if (vma->vm_file)
@ -306,7 +298,7 @@ aufs4.x-rcN mmap patch
put_nommu_region(vma->vm_region);
kmem_cache_free(vm_area_cachep, vma);
}
@@ -1354,7 +1354,7 @@ unsigned long do_mmap_pgoff(struct file
@@ -1354,7 +1354,7 @@ unsigned long do_mmap_pgoff(struct file *file,
goto error_just_free;
}
}
@ -328,6 +320,9 @@ aufs4.x-rcN mmap patch
kmem_cache_free(vm_area_cachep, vma);
return ret;
diff --git a/mm/prfile.c b/mm/prfile.c
new file mode 100644
index 0000000..b323b8a
--- /dev/null
+++ b/mm/prfile.c
@@ -0,0 +1,86 @@
@ -352,12 +347,11 @@ aufs4.x-rcN mmap patch
+{
+#ifdef PRFILE_TRACE
+ if (pr)
+ pr_info("%s:%d: %s, %p\n", func, line, func2,
+ pr_info("%s:%d: %s, %s\n", func, line, func2,
+ f ? (char *)f->f_path.dentry->d_name.name : "(null)");
+#endif
+}
+
+#ifdef CONFIG_MMU
+void vma_do_file_update_time(struct vm_area_struct *vma, const char func[],
+ int line)
+{
@ -397,7 +391,8 @@ aufs4.x-rcN mmap patch
+ if (f && pr)
+ fput(pr);
+}
+#else
+
+#ifndef CONFIG_MMU
+struct file *vmr_do_pr_or_file(struct vm_region *region, const char func[],
+ int line)
+{
@ -416,4 +411,4 @@ aufs4.x-rcN mmap patch
+ if (f && pr)
+ fput(pr);
+}
+#endif /* CONFIG_MMU */
+#endif /* !CONFIG_MMU */

View File

@ -1,15 +1,13 @@
From: J. R. Okajima <hooanon05@yahoo.co.jp>
Date: Sat Jun 6 21:25:05 2015 +0900
Date: Sat Sep 19 06:24:59 2015 +0900
Subject: aufs4.x-rcN standalone patch
Origin: https://github.com/sfjro/aufs4-standalone/tree/aa65d099b5220918a0509c91ece96b79f7cb4b2d
Origin: https://github.com/sfjro/aufs4-standalone/tree/4e2f15c8b322d41405616d118f13fe2c4abbf26f
Bug-Debian: https://bugs.debian.org/541828
Patch headers added by debian/patches/features/all/aufs4/gen-patch
aufs4.x-rcN standalone patch
[bwh: Adjusted context for 4.2]
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1272,6 +1272,7 @@ rename_retry: