All of lore.kernel.org
 help / color / mirror / Atom feed
From: Liping Zhang <zlpnobody@163.com>
To: akpm@linux-foundation.org, mingo@kernel.org, ebiederm@xmission.com
Cc: davem@davemloft.net, subashab@codeaurora.org,
	torvalds@linux-foundation.org, linux-kernel@vger.kernel.org,
	Liping Zhang <zlpnobody@gmail.com>
Subject: [PATCH 2/3] sysctl: don't print negative flag for proc_douintvec
Date: Fri,  7 Apr 2017 23:51:06 +0800	[thread overview]
Message-ID: <1491580267-36340-3-git-send-email-zlpnobody@163.com> (raw)
In-Reply-To: <1491580267-36340-1-git-send-email-zlpnobody@163.com>

From: Liping Zhang <zlpnobody@gmail.com>

I saw some very confusing sysctl output on my system:
  # cat /proc/sys/net/core/xfrm_aevent_rseqth
  -2
  # cat /proc/sys/net/core/xfrm_aevent_etime
  -10
  cat /proc/sys/net/ipv4/tcp_notsent_lowat
  -4294967295

Because we forget to set the *negp flag in proc_douintvec, so it will
become a garbage value.

Since the value related to proc_douintvec is always an unsigned integer,
so we can set *negp to false explictily to fix this issue.

Fixes: e7d316a02f68 ("sysctl: handle error writing UINT_MAX to u32 fields")
Signed-off-by: Liping Zhang <zlpnobody@gmail.com>
---
 kernel/sysctl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index acf0a5a..8cca4c7 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2136,6 +2136,7 @@ static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp,
 		*valp = *lvalp;
 	} else {
 		unsigned int val = *valp;
+		*negp = false;
 		*lvalp = (unsigned long)val;
 	}
 	return 0;
-- 
2.5.5

  parent reply	other threads:[~2017-04-07 15:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-07 15:51 [PATCH 0/3] sysctl: fix some bugs related to proc_douintvec Liping Zhang
2017-04-07 15:51 ` [PATCH 1/3] sysctl: add sanity check for proc_douintvec Liping Zhang
2017-04-07 15:51 ` Liping Zhang [this message]
2017-04-07 15:51 ` [PATCH 3/3] sysctl: report EINVAL if value is larger than UINT_MAX " Liping Zhang
2017-04-07 16:49   ` Linus Torvalds
2017-04-07 21:01     ` Eric W. Biederman
2017-04-08 17:21       ` Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1491580267-36340-3-git-send-email-zlpnobody@163.com \
    --to=zlpnobody@163.com \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=subashab@codeaurora.org \
    --cc=torvalds@linux-foundation.org \
    --cc=zlpnobody@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.