aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Lutomirski <luto@amacapital.net>2014-05-19 18:58:32 -0400
committerH. Peter Anvin <hpa@linux.intel.com>2014-05-20 14:36:31 -0400
commit78d683e838a60ec4ba4591cca4364cba84a9e626 (patch)
tree8b6760577295bf709d8567262b43eee5e8a86de2
parent1e844fb43c96dcdba3b578918f5c485d88750891 (diff)
mm, fs: Add vm_ops->name as an alternative to arch_vma_name
arch_vma_name sucks. It's a silly hack, and it's annoying to implement correctly. In fact, AFAICS, even the straightforward x86 implementation is incorrect (I suspect that it breaks if the vdso mapping is split or gets remapped). This adds a new vm_ops->name operation that can replace it. The followup patches will remove all uses of arch_vma_name on x86, fixing a couple of annoyances in the process. Signed-off-by: Andy Lutomirski <luto@amacapital.net> Link: http://lkml.kernel.org/r/2eee21791bb36a0a408c5c2bdb382a9e6a41ca4a.1400538962.git.luto@amacapital.net Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--fs/binfmt_elf.c8
-rw-r--r--fs/proc/task_mmu.c6
-rw-r--r--include/linux/mm.h6
3 files changed, 20 insertions, 0 deletions
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index aa3cb626671e..df9ea4186d75 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1108,6 +1108,14 @@ static bool always_dump_vma(struct vm_area_struct *vma)
1108 /* Any vsyscall mappings? */ 1108 /* Any vsyscall mappings? */
1109 if (vma == get_gate_vma(vma->vm_mm)) 1109 if (vma == get_gate_vma(vma->vm_mm))
1110 return true; 1110 return true;
1111
1112 /*
1113 * Assume that all vmas with a .name op should always be dumped.
1114 * If this changes, a new vm_ops field can easily be added.
1115 */
1116 if (vma->vm_ops && vma->vm_ops->name && vma->vm_ops->name(vma))
1117 return true;
1118
1111 /* 1119 /*
1112 * arch_vma_name() returns non-NULL for special architecture mappings, 1120 * arch_vma_name() returns non-NULL for special architecture mappings,
1113 * such as vDSO sections. 1121 * such as vDSO sections.
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 442177b1119a..9b2f5d62ce63 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -300,6 +300,12 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
300 goto done; 300 goto done;
301 } 301 }
302 302
303 if (vma->vm_ops && vma->vm_ops->name) {
304 name = vma->vm_ops->name(vma);
305 if (name)
306 goto done;
307 }
308
303 name = arch_vma_name(vma); 309 name = arch_vma_name(vma);
304 if (!name) { 310 if (!name) {
305 pid_t tid; 311 pid_t tid;
diff --git a/include/linux/mm.h b/include/linux/mm.h
index bf9811e1321a..63f8d4efe303 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -239,6 +239,12 @@ struct vm_operations_struct {
239 */ 239 */
240 int (*access)(struct vm_area_struct *vma, unsigned long addr, 240 int (*access)(struct vm_area_struct *vma, unsigned long addr,
241 void *buf, int len, int write); 241 void *buf, int len, int write);
242
243 /* Called by the /proc/PID/maps code to ask the vma whether it
244 * has a special name. Returning non-NULL will also cause this
245 * vma to be dumped unconditionally. */
246 const char *(*name)(struct vm_area_struct *vma);
247
242#ifdef CONFIG_NUMA 248#ifdef CONFIG_NUMA
243 /* 249 /*
244 * set_policy() op must add a reference to any non-NULL @new mempolicy 250 * set_policy() op must add a reference to any non-NULL @new mempolicy