kernel/sysctl.c: detect overflows when converting to int
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Thu, 16 Apr 2015 19:48:07 +0000 (12:48 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 17 Apr 2015 13:04:08 +0000 (09:04 -0400)
commit230633d109e35b0a24277498e773edeb79b4a331
treea9619a1bca9f70f5fb0f87b47bdb5493a6e72a8f
parent534b483a86e6b96f1b5cc03bbe4b696f3daead6d
kernel/sysctl.c: detect overflows when converting to int

When converting unsigned long to int overflows may occur.  These currently
are not detected when writing to the sysctl file system.

E.g. on a system where int has 32 bits and long has 64 bits
  echo 0x800001234 > /proc/sys/kernel/threads-max
has the same effect as
  echo 0x1234 > /proc/sys/kernel/threads-max

The patch adds the missing check in do_proc_dointvec_conv.

With the patch an overflow will result in an error EINVAL when writing to
the the sysctl file system.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
kernel/sysctl.c