aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sysctl.c
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2018-02-06 18:41:45 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-02-06 21:32:47 -0500
commit4c2e4befb3cc9ce42d506aa537c9ab504723e98c (patch)
tree5419e5965a7f07a39d1db8767148d547907f9c0d /kernel/sysctl.c
parente7c52b84fb18f08ce49b6067ae6285aca79084a8 (diff)
pipe, sysctl: drop 'min' parameter from pipe-max-size converter
Patch series "pipe: buffer limits fixes and cleanups", v2. This series simplifies the sysctl handler for pipe-max-size and fixes another set of bugs related to the pipe buffer limits: - The root user wasn't allowed to exceed the limits when creating new pipes. - There was an off-by-one error when checking the limits, so a limit of N was actually treated as N - 1. - F_SETPIPE_SZ accepted values over UINT_MAX. - Reading the pipe buffer limits could be racy. This patch (of 7): Before validating the given value against pipe_min_size, do_proc_dopipe_max_size_conv() calls round_pipe_size(), which rounds the value up to pipe_min_size. Therefore, the second check against pipe_min_size is redundant. Remove it. Link: http://lkml.kernel.org/r/20180111052902.14409-2-ebiggers3@gmail.com Signed-off-by: Eric Biggers <ebiggers@google.com> Acked-by: Kees Cook <keescook@chromium.org> Acked-by: Joe Lawrence <joe.lawrence@redhat.com> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: "Luis R . Rodriguez" <mcgrof@kernel.org> Cc: Michael Kerrisk <mtk.manpages@gmail.com> Cc: Mikulas Patocka <mpatocka@redhat.com> Cc: Willy Tarreau <w@1wt.eu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/sysctl.c')
-rw-r--r--kernel/sysctl.c15
1 files changed, 1 insertions, 14 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 2fb4e27c636a..f21375aa6cf6 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1813,7 +1813,6 @@ static struct ctl_table fs_table[] = {
1813 .maxlen = sizeof(pipe_max_size), 1813 .maxlen = sizeof(pipe_max_size),
1814 .mode = 0644, 1814 .mode = 0644,
1815 .proc_handler = &pipe_proc_fn, 1815 .proc_handler = &pipe_proc_fn,
1816 .extra1 = &pipe_min_size,
1817 }, 1816 },
1818 { 1817 {
1819 .procname = "pipe-user-pages-hard", 1818 .procname = "pipe-user-pages-hard",
@@ -2615,16 +2614,10 @@ int proc_douintvec_minmax(struct ctl_table *table, int write,
2615 do_proc_douintvec_minmax_conv, &param); 2614 do_proc_douintvec_minmax_conv, &param);
2616} 2615}
2617 2616
2618struct do_proc_dopipe_max_size_conv_param {
2619 unsigned int *min;
2620};
2621
2622static int do_proc_dopipe_max_size_conv(unsigned long *lvalp, 2617static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
2623 unsigned int *valp, 2618 unsigned int *valp,
2624 int write, void *data) 2619 int write, void *data)
2625{ 2620{
2626 struct do_proc_dopipe_max_size_conv_param *param = data;
2627
2628 if (write) { 2621 if (write) {
2629 unsigned int val; 2622 unsigned int val;
2630 2623
@@ -2635,9 +2628,6 @@ static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
2635 if (val == 0) 2628 if (val == 0)
2636 return -EINVAL; 2629 return -EINVAL;
2637 2630
2638 if (param->min && *param->min > val)
2639 return -ERANGE;
2640
2641 *valp = val; 2631 *valp = val;
2642 } else { 2632 } else {
2643 unsigned int val = *valp; 2633 unsigned int val = *valp;
@@ -2650,11 +2640,8 @@ static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
2650int proc_dopipe_max_size(struct ctl_table *table, int write, 2640int proc_dopipe_max_size(struct ctl_table *table, int write,
2651 void __user *buffer, size_t *lenp, loff_t *ppos) 2641 void __user *buffer, size_t *lenp, loff_t *ppos)
2652{ 2642{
2653 struct do_proc_dopipe_max_size_conv_param param = {
2654 .min = (unsigned int *) table->extra1,
2655 };
2656 return do_proc_douintvec(table, write, buffer, lenp, ppos, 2643 return do_proc_douintvec(table, write, buffer, lenp, ppos,
2657 do_proc_dopipe_max_size_conv, &param); 2644 do_proc_dopipe_max_size_conv, NULL);
2658} 2645}
2659 2646
2660static void validate_coredump_safety(void) 2647static void validate_coredump_safety(void)