提交 b8e51a6a 编写于 作者: Y Yihui ZENG 提交者: Vasily Gorbik

s390/cmm: fix information leak in cmm_timeout_handler()

The problem is that we were putting the NUL terminator too far:

	buf[sizeof(buf) - 1] = '\0';

If the user input isn't NUL terminated and they haven't initialized the
whole buffer then it leads to an info leak.  The NUL terminator should
be:

	buf[len - 1] = '\0';
Signed-off-by: NYihui Zeng <yzeng56@asu.edu>
Cc: stable@vger.kernel.org
Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
[heiko.carstens@de.ibm.com: keep semantics of how *lenp and *ppos are handled]
Signed-off-by: NHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: NVasily Gorbik <gor@linux.ibm.com>
上级 d6d5df1d
...@@ -298,16 +298,16 @@ static int cmm_timeout_handler(struct ctl_table *ctl, int write, ...@@ -298,16 +298,16 @@ static int cmm_timeout_handler(struct ctl_table *ctl, int write,
} }
if (write) { if (write) {
len = *lenp; len = min(*lenp, sizeof(buf));
if (copy_from_user(buf, buffer, if (copy_from_user(buf, buffer, len))
len > sizeof(buf) ? sizeof(buf) : len))
return -EFAULT; return -EFAULT;
buf[sizeof(buf) - 1] = '\0'; buf[len - 1] = '\0';
cmm_skip_blanks(buf, &p); cmm_skip_blanks(buf, &p);
nr = simple_strtoul(p, &p, 0); nr = simple_strtoul(p, &p, 0);
cmm_skip_blanks(p, &p); cmm_skip_blanks(p, &p);
seconds = simple_strtoul(p, &p, 0); seconds = simple_strtoul(p, &p, 0);
cmm_set_timeout(nr, seconds); cmm_set_timeout(nr, seconds);
*ppos += *lenp;
} else { } else {
len = sprintf(buf, "%ld %ld\n", len = sprintf(buf, "%ld %ld\n",
cmm_timeout_pages, cmm_timeout_seconds); cmm_timeout_pages, cmm_timeout_seconds);
...@@ -315,9 +315,9 @@ static int cmm_timeout_handler(struct ctl_table *ctl, int write, ...@@ -315,9 +315,9 @@ static int cmm_timeout_handler(struct ctl_table *ctl, int write,
len = *lenp; len = *lenp;
if (copy_to_user(buffer, buf, len)) if (copy_to_user(buffer, buf, len))
return -EFAULT; return -EFAULT;
*lenp = len;
*ppos += len;
} }
*lenp = len;
*ppos += len;
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册