@@ -50,8 +50,8 @@ static unsigned long mpx_mmap(unsigned long len)
return -EINVAL;
down_write(&mm->mmap_sem);
- addr = do_mmap(NULL, 0, len, PROT_READ | PROT_WRITE,
- MAP_ANONYMOUS | MAP_PRIVATE, VM_MPX, 0, &populate);
+ addr = do_mmap(mm, NULL, 0, len, PROT_READ | PROT_WRITE,
+ MAP_ANONYMOUS | MAP_PRIVATE, VM_MPX, 0, &populate);
up_write(&mm->mmap_sem);
if (populate)
mm_populate(addr, populate);
@@ -510,8 +510,8 @@ static int aio_setup_ring(struct kioctx *ctx)
return -EINTR;
}
- ctx->mmap_base = do_mmap_pgoff(ctx->aio_ring_file, 0, ctx->mmap_size,
- PROT_READ | PROT_WRITE,
+ ctx->mmap_base = do_mmap_pgoff(current->mm, ctx->aio_ring_file, 0,
+ ctx->mmap_size, PROT_READ | PROT_WRITE,
MAP_SHARED, 0, &unused);
up_write(&mm->mmap_sem);
if (IS_ERR((void *)ctx->mmap_base)) {
@@ -2019,17 +2019,18 @@ extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned lo
extern unsigned long mmap_region(struct mm_struct *mm, struct file *file,
unsigned long addr, unsigned long len,
vm_flags_t vm_flags, unsigned long pgoff);
-extern unsigned long do_mmap(struct file *file, unsigned long addr,
- unsigned long len, unsigned long prot, unsigned long flags,
- vm_flags_t vm_flags, unsigned long pgoff, unsigned long *populate);
+extern unsigned long do_mmap(struct mm_struct *mm, struct file *file,
+ unsigned long addr, unsigned long len, unsigned long prot,
+ unsigned long flags, vm_flags_t vm_flags, unsigned long pgoff,
+ unsigned long *populate);
extern int do_munmap(struct mm_struct *, unsigned long, size_t);
static inline unsigned long
-do_mmap_pgoff(struct file *file, unsigned long addr,
+do_mmap_pgoff(struct mm_struct *mm, struct file *file, unsigned long addr,
unsigned long len, unsigned long prot, unsigned long flags,
unsigned long pgoff, unsigned long *populate)
{
- return do_mmap(file, addr, len, prot, flags, 0, pgoff, populate);
+ return do_mmap(mm, file, addr, len, prot, flags, 0, pgoff, populate);
}
#ifdef CONFIG_MMU
@@ -1222,7 +1222,8 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
goto invalid;
}
- addr = do_mmap_pgoff(file, addr, size, prot, flags, 0, &populate);
+ addr = do_mmap_pgoff(mm, file, addr, size, prot, flags, 0,
+ &populate);
*raddr = addr;
err = 0;
if (IS_ERR_VALUE(addr))
@@ -1299,14 +1299,14 @@ static inline int mlock_future_check(struct mm_struct *mm,
}
/*
- * The caller must hold down_write(¤t->mm->mmap_sem).
+ * The caller must hold down_write(&mm->mmap_sem).
*/
-unsigned long do_mmap(struct file *file, unsigned long addr,
- unsigned long len, unsigned long prot,
- unsigned long flags, vm_flags_t vm_flags,
- unsigned long pgoff, unsigned long *populate)
+unsigned long do_mmap(struct mm_struct *mm, struct file *file,
+ unsigned long addr, unsigned long len,
+ unsigned long prot, unsigned long flags,
+ vm_flags_t vm_flags, unsigned long pgoff,
+ unsigned long *populate)
{
- struct mm_struct *mm = current->mm;
int pkey = 0;
*populate = 0;
@@ -2779,8 +2779,8 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
}
file = get_file(vma->vm_file);
- ret = do_mmap_pgoff(vma->vm_file, start, size,
- prot, flags, pgoff, &populate);
+ ret = do_mmap_pgoff(mm, vma->vm_file, start, size,
+ prot, flags, pgoff, &populate);
fput(file);
out:
up_write(&mm->mmap_sem);
@@ -1198,7 +1198,8 @@ static int do_mmap_private(struct vm_area_struct *vma,
/*
* handle mapping creation for uClinux
*/
-unsigned long do_mmap(struct file *file,
+unsigned long do_mmap(struct mm_struct *mm,
+ struct file *file,
unsigned long addr,
unsigned long len,
unsigned long prot,
@@ -1375,10 +1376,10 @@ unsigned long do_mmap(struct file *file,
/* okay... we have a mapping; now we have to register it */
result = vma->vm_start;
- current->mm->total_vm += len >> PAGE_SHIFT;
+ mm->total_vm += len >> PAGE_SHIFT;
share:
- add_vma_to_mm(current->mm, vma);
+ add_vma_to_mm(mm, vma);
/* we flush the region from the icache only when the first executable
* mapping of it is made */
@@ -302,7 +302,7 @@ unsigned long vm_mmap_pgoff(struct file *file, unsigned long addr,
if (!ret) {
if (down_write_killable(&mm->mmap_sem))
return -EINTR;
- ret = do_mmap_pgoff(file, addr, len, prot, flag, pgoff,
+ ret = do_mmap_pgoff(mm, file, addr, len, prot, flag, pgoff,
&populate);
up_write(&mm->mmap_sem);
if (populate)
Add to the 'do_mmap' and 'do_mmap_pgoff' functions the mm_struct they should operate on as additional argument. Before, both functions simply used the memory map of the current task. However, with the introduction of first class virtual address spaces, these functions also need to be usable for other memory maps than just the one of the current process. Hence, explicitly define during the function call which memory map to use. Signed-off-by: Till Smejkal <till.smejkal@gmail.com> --- arch/x86/mm/mpx.c | 4 ++-- fs/aio.c | 4 ++-- include/linux/mm.h | 11 ++++++----- ipc/shm.c | 3 ++- mm/mmap.c | 16 ++++++++-------- mm/nommu.c | 7 ++++--- mm/util.c | 2 +- 7 files changed, 25 insertions(+), 22 deletions(-)