All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] kernel/sysctl.c: avoid overflow
@ 2016-06-11  1:33 Heinrich Schuchardt
  2016-06-14 18:33 ` Kees Cook
  2016-06-14 20:19 ` Andrew Morton
  0 siblings, 2 replies; 8+ messages in thread
From: Heinrich Schuchardt @ 2016-06-11  1:33 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Arnaldo Carvalho de Melo, Kees Cook, Don Zickus, Al Viro,
	Dave Young, Hugh Dickins, Thomas Gleixner, Daniel Cashman,
	Willy Tarreau, Alexei Starovoitov, Eric W. Biederman,
	Ilya Dryomov, linux-kernel, Heinrich Schuchardt

An undetected overflow may occur in do_proc_dointvec_minmax_conv_param.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 kernel/sysctl.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 35f0dcb..a9e7be3 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2313,7 +2313,17 @@ static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
 {
 	struct do_proc_dointvec_minmax_conv_param *param = data;
 	if (write) {
-		int val = *negp ? -*lvalp : *lvalp;
+		int val;
+
+		if (*negp) {
+			if (*lvalp > (unsigned long) INT_MAX + 1)
+				return -EINVAL;
+			val = -*lvalp;
+		} else {
+			if (*lvalp > (unsigned long) INT_MAX)
+				return -EINVAL;
+			val = *lvalp;
+		}
 		if ((param->min && *param->min > val) ||
 		    (param->max && *param->max < val))
 			return -EINVAL;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-06-15  8:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-11  1:33 [PATCH 1/1] kernel/sysctl.c: avoid overflow Heinrich Schuchardt
2016-06-14 18:33 ` Kees Cook
2016-06-14 20:19 ` Andrew Morton
2016-06-14 20:41   ` Willy Tarreau
2016-06-15  8:33     ` Dave Young
2016-06-15  8:40       ` Willy Tarreau
2016-06-15  8:50         ` Dave Young
2016-06-14 21:05   ` Kees Cook

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.