1 From 8cf7630b29701d364f8df4a50e4f1f5e752b2778 Mon Sep 17 00:00:00 2001
2 From: Zev Weiss <zev@bewilderbeest.net>
3 Date: Mon, 11 Mar 2019 23:28:02 -0700
4 Subject: kernel/sysctl.c: add missing range check in do_proc_dointvec_minmax_conv
6 From: Zev Weiss <zev@bewilderbeest.net>
8 commit 8cf7630b29701d364f8df4a50e4f1f5e752b2778 upstream.
10 This bug has apparently existed since the introduction of this function
11 in the pre-git era (4500e91754d3 in Thomas Gleixner's history.git,
12 "[NET]: Add proc_dointvec_userhz_jiffies, use it for proper handling of
15 As a minimal fix we can simply duplicate the corresponding check in
16 do_proc_dointvec_conv().
18 Link: http://lkml.kernel.org/r/20190207123426.9202-3-zev@bewilderbeest.net
19 Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
20 Cc: Brendan Higgins <brendanhiggins@google.com>
21 Cc: Iurii Zaikin <yzaikin@google.com>
22 Cc: Kees Cook <keescook@chromium.org>
23 Cc: Luis Chamberlain <mcgrof@kernel.org>
24 Cc: <stable@vger.kernel.org> [2.6.2+]
25 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
26 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
27 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
30 kernel/sysctl.c | 11 ++++++++++-
31 1 file changed, 10 insertions(+), 1 deletion(-)
35 @@ -2579,7 +2579,16 @@ static int do_proc_dointvec_minmax_conv(
37 struct do_proc_dointvec_minmax_conv_param *param = data;
39 - int val = *negp ? -*lvalp : *lvalp;
42 + if (*lvalp > (unsigned long) INT_MAX + 1)
46 + if (*lvalp > (unsigned long) INT_MAX)
50 if ((param->min && *param->min > val) ||
51 (param->max && *param->max < val))