Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 106187
b: refs/heads/master
c: bc40d73
h: refs/heads/master
i:
  106185: e5f03a4
  106183: d729013
v: v3
  • Loading branch information
Nick Piggin authored and Linus Torvalds committed Jul 26, 2008
1 parent ae1f1d4 commit edfb1f3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 39 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: f5dd33c494a427b1d1a3b574de5c9e511c888864
refs/heads/master: bc40d73c950146725e9e768e856a416ec8949065
41 changes: 3 additions & 38 deletions trunk/fs/splice.c
Original file line number Diff line number Diff line change
Expand Up @@ -1160,36 +1160,6 @@ static long do_splice(struct file *in, loff_t __user *off_in,
return -EINVAL;
}

/*
* Do a copy-from-user while holding the mmap_semaphore for reading, in a
* manner safe from deadlocking with simultaneous mmap() (grabbing mmap_sem
* for writing) and page faulting on the user memory pointed to by src.
* This assumes that we will very rarely hit the partial != 0 path, or this
* will not be a win.
*/
static int copy_from_user_mmap_sem(void *dst, const void __user *src, size_t n)
{
int partial;

if (!access_ok(VERIFY_READ, src, n))
return -EFAULT;

pagefault_disable();
partial = __copy_from_user_inatomic(dst, src, n);
pagefault_enable();

/*
* Didn't copy everything, drop the mmap_sem and do a faulting copy
*/
if (unlikely(partial)) {
up_read(&current->mm->mmap_sem);
partial = copy_from_user(dst, src, n);
down_read(&current->mm->mmap_sem);
}

return partial;
}

/*
* Map an iov into an array of pages and offset/length tupples. With the
* partial_page structure, we can map several non-contiguous ranges into
Expand All @@ -1203,8 +1173,6 @@ static int get_iovec_page_array(const struct iovec __user *iov,
{
int buffers = 0, error = 0;

down_read(&current->mm->mmap_sem);

while (nr_vecs) {
unsigned long off, npages;
struct iovec entry;
Expand All @@ -1213,7 +1181,7 @@ static int get_iovec_page_array(const struct iovec __user *iov,
int i;

error = -EFAULT;
if (copy_from_user_mmap_sem(&entry, iov, sizeof(entry)))
if (copy_from_user(&entry, iov, sizeof(entry)))
break;

base = entry.iov_base;
Expand Down Expand Up @@ -1247,9 +1215,8 @@ static int get_iovec_page_array(const struct iovec __user *iov,
if (npages > PIPE_BUFFERS - buffers)
npages = PIPE_BUFFERS - buffers;

error = get_user_pages(current, current->mm,
(unsigned long) base, npages, 0, 0,
&pages[buffers], NULL);
error = get_user_pages_fast((unsigned long)base, npages,
0, &pages[buffers]);

if (unlikely(error <= 0))
break;
Expand Down Expand Up @@ -1288,8 +1255,6 @@ static int get_iovec_page_array(const struct iovec __user *iov,
iov++;
}

up_read(&current->mm->mmap_sem);

if (buffers)
return buffers;

Expand Down

0 comments on commit edfb1f3

Please sign in to comment.