From: Liping Zhang Date: Fri, 7 Apr 2017 15:51:07 +0000 (+0800) Subject: sysctl: report EINVAL if value is larger than UINT_MAX for proc_douintvec X-Git-Tag: MMI-PSA29.97-13-9~5854 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=425fffd886bae3d127a08fa6a17f2e31e24ed7ff;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git sysctl: report EINVAL if value is larger than UINT_MAX for proc_douintvec 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: e7d316a02f68 ("sysctl: handle error writing UINT_MAX to u32 fields") Signed-off-by: Liping Zhang Cc: Subash Abhinov Kasiviswanathan Cc: Andrew Morton Cc: Eric W. Biederman Signed-off-by: Linus Torvalds --- diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 8cca4c7bb21f..8c8714fcb53c 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2133,6 +2133,8 @@ static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp, if (write) { if (*negp) return -EINVAL; + if (*lvalp > UINT_MAX) + return -EINVAL; *valp = *lvalp; } else { unsigned int val = *valp;