diff options
Diffstat (limited to 'fs/pipe.c')
-rw-r--r-- | fs/pipe.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -19,11 +19,18 @@ | |||
19 | #include <linux/pagemap.h> | 19 | #include <linux/pagemap.h> |
20 | #include <linux/audit.h> | 20 | #include <linux/audit.h> |
21 | #include <linux/syscalls.h> | 21 | #include <linux/syscalls.h> |
22 | #include <linux/fcntl.h> | ||
22 | 23 | ||
23 | #include <asm/uaccess.h> | 24 | #include <asm/uaccess.h> |
24 | #include <asm/ioctls.h> | 25 | #include <asm/ioctls.h> |
25 | 26 | ||
26 | /* | 27 | /* |
28 | * The max size that a non-root user is allowed to grow the pipe. Can | ||
29 | * be set by root in /proc/sys/fs/pipe-max-pages | ||
30 | */ | ||
31 | unsigned int pipe_max_pages = PIPE_DEF_BUFFERS * 16; | ||
32 | |||
33 | /* | ||
27 | * We use a start+len construction, which provides full use of the | 34 | * We use a start+len construction, which provides full use of the |
28 | * allocated memory. | 35 | * allocated memory. |
29 | * -- Florian Coosmann (FGC) | 36 | * -- Florian Coosmann (FGC) |
@@ -1162,6 +1169,14 @@ long pipe_fcntl(struct file *file, unsigned int cmd, unsigned long arg) | |||
1162 | 1169 | ||
1163 | switch (cmd) { | 1170 | switch (cmd) { |
1164 | case F_SETPIPE_SZ: | 1171 | case F_SETPIPE_SZ: |
1172 | if (!capable(CAP_SYS_ADMIN) && arg > pipe_max_pages) | ||
1173 | return -EINVAL; | ||
1174 | /* | ||
1175 | * The pipe needs to be at least 2 pages large to | ||
1176 | * guarantee POSIX behaviour. | ||
1177 | */ | ||
1178 | if (arg < 2) | ||
1179 | return -EINVAL; | ||
1165 | ret = pipe_set_size(pipe, arg); | 1180 | ret = pipe_set_size(pipe, arg); |
1166 | break; | 1181 | break; |
1167 | case F_GETPIPE_SZ: | 1182 | case F_GETPIPE_SZ: |