Commit 7bdacd3d authored by Liping Zhang's avatar Liping Zhang Committed by Greg Kroah-Hartman

sysctl: report EINVAL if value is larger than UINT_MAX for proc_douintvec

commit 425fffd8 upstream.

Currently, inputting the following command will succeed but actually the
value will be truncated:

  # echo 0x12ffffffff > /proc/sys/net/ipv4/tcp_notsent_lowat

This is not friendly to the user, so instead, we should report error
when the value is larger than UINT_MAX.

Fixes: e7d316a0 ("sysctl: handle error writing UINT_MAX to u32 fields")
Signed-off-by: default avatarLiping Zhang <zlpnobody@gmail.com>
Cc: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3a20c57b
...@@ -2146,6 +2146,8 @@ static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp, ...@@ -2146,6 +2146,8 @@ static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp,
if (write) { if (write) {
if (*negp) if (*negp)
return -EINVAL; return -EINVAL;
if (*lvalp > UINT_MAX)
return -EINVAL;
*valp = *lvalp; *valp = *lvalp;
} else { } else {
unsigned int val = *valp; unsigned int val = *valp;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment