Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 243393
b: refs/heads/master
c: f55f199
h: refs/heads/master
i:
  243391: f50f473
v: v3
  • Loading branch information
Mike Frysinger authored and David Howells committed Mar 29, 2011
1 parent 1cfce70 commit 6006c69
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b554cb426a955a267dba524f98f99e29bc947643
refs/heads/master: f55f199b7d76a01e7ce9d1c3bb004327e075c327
52 changes: 39 additions & 13 deletions trunk/mm/nommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1971,21 +1971,10 @@ int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
}
EXPORT_SYMBOL(filemap_fault);

/*
* Access another process' address space.
* - source/target buffer must be kernel space
*/
int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
unsigned long addr, void *buf, int len, int write)
{
struct vm_area_struct *vma;
struct mm_struct *mm;

if (addr + len < addr)
return 0;

mm = get_task_mm(tsk);
if (!mm)
return 0;

down_read(&mm->mmap_sem);

Expand All @@ -2010,6 +1999,43 @@ int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, in
}

up_read(&mm->mmap_sem);

return len;
}

/**
* @access_remote_vm - access another process' address space
* @mm: the mm_struct of the target address space
* @addr: start address to access
* @buf: source or destination buffer
* @len: number of bytes to transfer
* @write: whether the access is a write
*
* The caller must hold a reference on @mm.
*/
int access_remote_vm(struct mm_struct *mm, unsigned long addr,
void *buf, int len, int write)
{
return __access_remote_vm(NULL, mm, addr, buf, len, write);
}

/*
* Access another process' address space.
* - source/target buffer must be kernel space
*/
int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
{
struct mm_struct *mm;

if (addr + len < addr)
return 0;

mm = get_task_mm(tsk);
if (!mm)
return 0;

len = __access_remote_vm(tsk, mm, addr, buf, len, write);

mmput(mm);
return len;
}
Expand Down

0 comments on commit 6006c69

Please sign in to comment.