diff options
author | Miklos Szeredi <mszeredi@suse.cz> | 2014-05-27 10:41:16 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-05-28 01:54:52 -0400 |
commit | b6dd6f4738837439c520e73995ec93fe1de2ec72 (patch) | |
tree | 625ca1eb1d708ea7ceccba35362ee6ffa1daf9da /fs | |
parent | c7208164e66f63e3ec1759b98087849286410741 (diff) |
vfs: fix vmplice_to_user()
Commit 6130f5315ee8 "switch vmsplice_to_user() to copy_page_to_iter()" in
v3.15-rc1 broke vmsplice(2).
This patch fixes two bugs:
- count is not initialized to a proper value, which resulted in no data
being copied
- if rw_copy_check_uvector() returns negative then the iov might be leaked.
Tested OK.
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/splice.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/splice.c b/fs/splice.c index 9bc07d2b53cf..e246954ea48c 100644 --- a/fs/splice.c +++ b/fs/splice.c | |||
@@ -1537,7 +1537,7 @@ static long vmsplice_to_user(struct file *file, const struct iovec __user *uiov, | |||
1537 | struct iovec iovstack[UIO_FASTIOV]; | 1537 | struct iovec iovstack[UIO_FASTIOV]; |
1538 | struct iovec *iov = iovstack; | 1538 | struct iovec *iov = iovstack; |
1539 | struct iov_iter iter; | 1539 | struct iov_iter iter; |
1540 | ssize_t count = 0; | 1540 | ssize_t count; |
1541 | 1541 | ||
1542 | pipe = get_pipe_info(file); | 1542 | pipe = get_pipe_info(file); |
1543 | if (!pipe) | 1543 | if (!pipe) |
@@ -1546,8 +1546,9 @@ static long vmsplice_to_user(struct file *file, const struct iovec __user *uiov, | |||
1546 | ret = rw_copy_check_uvector(READ, uiov, nr_segs, | 1546 | ret = rw_copy_check_uvector(READ, uiov, nr_segs, |
1547 | ARRAY_SIZE(iovstack), iovstack, &iov); | 1547 | ARRAY_SIZE(iovstack), iovstack, &iov); |
1548 | if (ret <= 0) | 1548 | if (ret <= 0) |
1549 | return ret; | 1549 | goto out; |
1550 | 1550 | ||
1551 | count = ret; | ||
1551 | iov_iter_init(&iter, iov, nr_segs, count, 0); | 1552 | iov_iter_init(&iter, iov, nr_segs, count, 0); |
1552 | 1553 | ||
1553 | sd.len = 0; | 1554 | sd.len = 0; |
@@ -1560,6 +1561,7 @@ static long vmsplice_to_user(struct file *file, const struct iovec __user *uiov, | |||
1560 | ret = __splice_from_pipe(pipe, &sd, pipe_to_user); | 1561 | ret = __splice_from_pipe(pipe, &sd, pipe_to_user); |
1561 | pipe_unlock(pipe); | 1562 | pipe_unlock(pipe); |
1562 | 1563 | ||
1564 | out: | ||
1563 | if (iov != iovstack) | 1565 | if (iov != iovstack) |
1564 | kfree(iov); | 1566 | kfree(iov); |
1565 | 1567 | ||