Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1618921

[PATCH 3/3] sysctl: report EINVAL if value is larger than UINT_MAX for proc_douintvec

From Liping Zhang <zlpnobody@163.com>
Newsgroups linux.kernel
Subject [PATCH 3/3] sysctl: report EINVAL if value is larger than UINT_MAX for proc_douintvec
Date 2017-04-07 18:00 +0200
Message-ID <ttEsN-K9-3@gated-at.bofh.it> (permalink)
References <ttEsN-K9-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Liping Zhang <zlpnobody@gmail.com>

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>
---
 kernel/sysctl.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 8cca4c7..e8d1ed0 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 > (unsigned long) UINT_MAX)
+			return -EINVAL;
 		*valp = *lvalp;
 	} else {
 		unsigned int val = *valp;
-- 
2.5.5

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH 3/3] sysctl: report EINVAL if value is larger than UINT_MAX for proc_douintvec Liping Zhang <zlpnobody@163.com> - 2017-04-07 18:00 +0200
  Re: [PATCH 3/3] sysctl: report EINVAL if value is larger than  UINT_MAX for proc_douintvec Linus Torvalds <torvalds@linux-foundation.org> - 2017-04-07 19:00 +0200
    Re: [PATCH 3/3] sysctl: report EINVAL if value is larger than UINT_MAX for proc_douintvec ebiederm@xmission.com (Eric W. Biederman) - 2017-04-07 23:10 +0200
      Re: [PATCH 3/3] sysctl: report EINVAL if value is larger than  UINT_MAX for proc_douintvec Linus Torvalds <torvalds@linux-foundation.org> - 2017-04-08 19:30 +0200

csiph-web