mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 12:28:41 +08:00
iov_iter_get_pages{,_alloc}(): cap the maxsize with MAX_RW_COUNT
All callers can and should handle iov_iter_get_pages() returning fewer pages than requested. All in-kernel ones do. And it makes the arithmetical overflow analysis much simpler... Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
18fa9af726
commit
7392ed1734
@ -1348,6 +1348,8 @@ ssize_t iov_iter_get_pages(struct iov_iter *i,
|
|||||||
maxsize = i->count;
|
maxsize = i->count;
|
||||||
if (!maxsize)
|
if (!maxsize)
|
||||||
return 0;
|
return 0;
|
||||||
|
if (maxsize > MAX_RW_COUNT)
|
||||||
|
maxsize = MAX_RW_COUNT;
|
||||||
|
|
||||||
if (likely(iter_is_iovec(i))) {
|
if (likely(iter_is_iovec(i))) {
|
||||||
unsigned int gup_flags = 0;
|
unsigned int gup_flags = 0;
|
||||||
@ -1474,6 +1476,8 @@ ssize_t iov_iter_get_pages_alloc(struct iov_iter *i,
|
|||||||
maxsize = i->count;
|
maxsize = i->count;
|
||||||
if (!maxsize)
|
if (!maxsize)
|
||||||
return 0;
|
return 0;
|
||||||
|
if (maxsize > MAX_RW_COUNT)
|
||||||
|
maxsize = MAX_RW_COUNT;
|
||||||
|
|
||||||
if (likely(iter_is_iovec(i))) {
|
if (likely(iter_is_iovec(i))) {
|
||||||
unsigned int gup_flags = 0;
|
unsigned int gup_flags = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user