瀏覽代碼

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 <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: Linus Torvalds <torvalds@linux-foundation.org>
Liping Zhang 8 年之前
父節點
當前提交
425fffd886
共有 1 個文件被更改,包括 2 次插入0 次删除
  1. 2 0
      kernel/sysctl.c

+ 2 - 0
kernel/sysctl.c

@@ -2133,6 +2133,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;