From: Aristeu Rozanski <aris@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: "Luis R. Rodriguez" <mcgrof@kernel.org>,
Kees Cook <keescook@chromium.org>
Subject: [PATCH] sysctl: do not allow a 64bit value write in a 32bit knob
Date: Mon, 27 Aug 2018 16:27:06 -0400 [thread overview]
Message-ID: <20180827202706.olt3saqjzzzyax6i@redhat.com> (raw)
Writing to a sysctl file that uses proc_dointvec_minmax like user/max_uts_namespaces
a larger than 32 bit value won't cause an error as expected but instead will zero
its value:
# echo 214748364800000 > max_uts_namespaces
# cat max_uts_namespaces
0
This patches fixes it.
Signed-off-by: Aristeu Rozanski <aris@redhat.com>
Cc: "Luis R. Rodriguez" <mcgrof@kernel.org>
Cc: Kees Cook <keescook@chromium.org>
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 4ac9b9a..243f277 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2486,7 +2486,8 @@ static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
if (write) {
int val = *negp ? -*lvalp : *lvalp;
if ((param->min && *param->min > val) ||
- (param->max && *param->max < val))
+ (param->max && *param->max < val) ||
+ *lvalp >> (sizeof(int) * 8))
return -EINVAL;
*valp = val;
} else {
next reply other threads:[~2018-08-27 20:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-27 20:27 Aristeu Rozanski [this message]
2018-08-28 4:43 ` kbuild test robot
2018-08-28 7:21 ` kbuild test robot
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=20180827202706.olt3saqjzzzyax6i@redhat.com \
--to=aris@redhat.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®