lkml.org 
[lkml]   [2015]   [Mar]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/3] sysctl: detect overflows in proc_get_long
Date
When converting strings to unsigned long overflows may occur.
These currently are not detected.

E.g. on a 32bit system
echo 0x800001234 > /proc/sys/kernel/threads-max
has the same effect as
echo 0x1234 > /proc/sys/kernel/threads-max

The patch replaces the call to deprecated simple_strtoul by a call
to kstrtoul_e.

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

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 88ea2d6..4d9d139 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1884,7 +1884,8 @@ static int proc_get_long(char **buf, size_t *size,
if (!isdigit(*p))
return -EINVAL;

- *val = simple_strtoul(p, &p, 0);
+ if (kstrtoul_e(p, &p, 0, val) < 0)
+ return -EINVAL;

len = p - tmp;

--
2.1.4


\
 
 \ /
  Last update: 2015-03-29 22:21    [W:0.087 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site