Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1463737
| From | Vegard Nossum <vegard.nossum@oracle.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 1/2] pipe: check limits only when increasing pipe capacity |
| Date | 2016-08-16 14:00 +0200 |
| Message-ID | <s6Lce-2BC-29@gated-at.bofh.it> (permalink) |
| References | <s6Kzw-2mV-21@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 08/16/2016 01:10 PM, Michael Kerrisk (man-pages) wrote:
> When changing a pipe's capacity with fcntl(F_SETPIPE_SZ), various
> limits defined by /proc/sys/fs/pipe-* files are checked to see
> if unprivileged users are exceeding limits on memory consumption.
>
[...]
> ---
> fs/pipe.c | 25 +++++++++++++++++--------
> 1 file changed, 17 insertions(+), 8 deletions(-)
>
> diff --git a/fs/pipe.c b/fs/pipe.c
> index 4ebe6b2..a98ebca 100644
> --- a/fs/pipe.c
> +++ b/fs/pipe.c
> @@ -1122,14 +1122,23 @@ long pipe_fcntl(struct file *file, unsigned int cmd, unsigned long arg)
> if (!nr_pages)
> goto out;
>
> - if (!capable(CAP_SYS_RESOURCE) && size > pipe_max_size) {
> - ret = -EPERM;
> - goto out;
> - } else if ((too_many_pipe_buffers_hard(pipe->user) ||
> - too_many_pipe_buffers_soft(pipe->user)) &&
> - !capable(CAP_SYS_RESOURCE) && !capable(CAP_SYS_ADMIN)) {
> - ret = -EPERM;
> - goto out;
> + /*
> + * If trying to increase the pipe capacity, check that an
> + * unprivileged user is not trying to exceed various limits.
> + * (Decreasing the pipe capacity is always permitted, even
> + * if the user is currently over a limit.)
> + */
> + if (nr_pages > pipe->buffers) {
> + if (!capable(CAP_SYS_RESOURCE) && size > pipe_max_size) {
> + ret = -EPERM;
> + goto out;
> + } else if ((too_many_pipe_buffers_hard(pipe->user) ||
> + too_many_pipe_buffers_soft(pipe->user)) &&
> + !capable(CAP_SYS_RESOURCE) &&
> + !capable(CAP_SYS_ADMIN)) {
> + ret = -EPERM;
> + goto out;
> + }
> }
> ret = pipe_set_size(pipe, nr_pages);
> break;
>
FWIW: Reviewed-by: Vegard Nossum <vegard.nossum@oracle.com>
Vegard
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 1/2] pipe: check limits only when increasing pipe capacity "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> - 2016-08-16 13:20 +0200
[PATCH 2/2] pipe: make pipe user buffer limit checks more precise "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> - 2016-08-16 13:20 +0200
Re: [PATCH 2/2] pipe: make pipe user buffer limit checks more precise Vegard Nossum <vegard.nossum@oracle.com> - 2016-08-16 14:10 +0200
Re: [PATCH 2/2] pipe: make pipe user buffer limit checks more precise "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> - 2016-08-16 22:30 +0200
Re: [PATCH 2/2] pipe: make pipe user buffer limit checks more precise Vegard Nossum <vegard.nossum@oracle.com> - 2016-08-17 00:10 +0200
Re: [PATCH 2/2] pipe: make pipe user buffer limit checks more precise "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> - 2016-08-17 10:10 +0200
Re: [PATCH 2/2] pipe: make pipe user buffer limit checks more precise Vegard Nossum <vegard.nossum@oracle.com> - 2016-08-17 21:40 +0200
Re: [PATCH 2/2] pipe: make pipe user buffer limit checks more precise "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> - 2016-08-17 21:50 +0200
Re: [PATCH 2/2] pipe: make pipe user buffer limit checks more precise Vegard Nossum <vegard.nossum@oracle.com> - 2016-08-17 22:00 +0200
Re: [PATCH 2/2] pipe: make pipe user buffer limit checks more precise "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> - 2016-08-19 07:20 +0200
Re: [PATCH 1/2] pipe: check limits only when increasing pipe capacity Vegard Nossum <vegard.nossum@oracle.com> - 2016-08-16 14:00 +0200
Re: [PATCH 1/2] pipe: check limits only when increasing pipe capacity "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> - 2016-08-19 07:20 +0200
csiph-web