Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 87303
b: refs/heads/master
c: fb39380
h: refs/heads/master
i:
  87301: c31c594
  87299: 3621edf
  87295: 47bd6e8
v: v3
  • Loading branch information
Marcelo Tosatti authored and Linus Torvalds committed Mar 13, 2008
1 parent 082ec21 commit e318dd9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 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: b500ce8d24d1f14426643da5f6fada28c1f60533
refs/heads/master: fb39380b8d683b55630ba5ba381f4e43e417420e
18 changes: 13 additions & 5 deletions trunk/fs/proc/task_mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -640,25 +640,25 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,

ret = -EACCES;
if (!ptrace_may_attach(task))
goto out;
goto out_task;

ret = -EINVAL;
/* file position must be aligned */
if (*ppos % PM_ENTRY_BYTES)
goto out;
goto out_task;

ret = 0;
mm = get_task_mm(task);
if (!mm)
goto out;
goto out_task;

ret = -ENOMEM;
uaddr = (unsigned long)buf & PAGE_MASK;
uend = (unsigned long)(buf + count);
pagecount = (PAGE_ALIGN(uend) - uaddr) / PAGE_SIZE;
pages = kmalloc(pagecount * sizeof(struct page *), GFP_KERNEL);
if (!pages)
goto out_task;
goto out_mm;

down_read(&current->mm->mmap_sem);
ret = get_user_pages(current, current->mm, uaddr, pagecount,
Expand All @@ -668,6 +668,12 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
if (ret < 0)
goto out_free;

if (ret != pagecount) {
pagecount = ret;
ret = -EFAULT;
goto out_pages;
}

pm.out = buf;
pm.end = buf + count;

Expand Down Expand Up @@ -699,15 +705,17 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
ret = pm.out - buf;
}

out_pages:
for (; pagecount; pagecount--) {
page = pages[pagecount-1];
if (!PageReserved(page))
SetPageDirty(page);
page_cache_release(page);
}
mmput(mm);
out_free:
kfree(pages);
out_mm:
mmput(mm);
out_task:
put_task_struct(task);
out:
Expand Down

0 comments on commit e318dd9

Please sign in to comment.