pipe: fix check in "set size" fcntl
As it stands this check compares the number of pages to the page size. This makes no sense and makes the fcntl fail in almost any sane case. Fix it by checking if nr_pages is not zero (it can become zero only if arg is too big and round_pipe_size() overflows). Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
This commit is contained in:
Родитель
1d862f4122
Коммит
6db40cf047
|
@ -1215,12 +1215,13 @@ long pipe_fcntl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||||
size = round_pipe_size(arg);
|
size = round_pipe_size(arg);
|
||||||
nr_pages = size >> PAGE_SHIFT;
|
nr_pages = size >> PAGE_SHIFT;
|
||||||
|
|
||||||
|
ret = -EINVAL;
|
||||||
|
if (!nr_pages)
|
||||||
|
goto out;
|
||||||
|
|
||||||
if (!capable(CAP_SYS_RESOURCE) && size > pipe_max_size) {
|
if (!capable(CAP_SYS_RESOURCE) && size > pipe_max_size) {
|
||||||
ret = -EPERM;
|
ret = -EPERM;
|
||||||
goto out;
|
goto out;
|
||||||
} else if (nr_pages < PAGE_SIZE) {
|
|
||||||
ret = -EINVAL;
|
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
ret = pipe_set_size(pipe, nr_pages);
|
ret = pipe_set_size(pipe, nr_pages);
|
||||||
break;
|
break;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче