From: Lukasz Odzioba <lukasz.odzioba@intel.com>
To: linux-kernel@vger.kernel.org, tglx@linutronix.de,
mingo@redhat.com, hpa@zytor.com, x86@kernel.org, bp@alien8.de,
luto@kernel.org, slaoub@gmail.com, bp@suse.de,
dave.hansen@linux.intel.com, andi.kleen@intel.com
Cc: Lukasz Odzioba <lukasz.odzioba@intel.com>
Subject: [PATCH 1/1] x86: sanitize argument of clearcpuid command-line option
Date: Wed, 28 Dec 2016 14:55:40 +0100 [thread overview]
Message-ID: <1482933340-11857-1-git-send-email-lukasz.odzioba@intel.com> (raw)
A negative number can be specified in the cmdline which will be used as
setup_clear_cpu_cap() argument. With that we can clear/set some bit in
memory predceeding boot_cpu_data/cpu_caps_cleared which may cause kernel
to misbehave. This patch adds lower bound check to setup_disablecpuid().
Fixes: ac72e7888a61 ("x86: add generic clearcpuid=... option")
Signed-off-by: Lukasz Odzioba <lukasz.odzioba@intel.com>
---
As an example let's change definition of one_hundred variable:
ffffffff81c4eeec d one_hundred
ffffffff81d69720 D boot_cpu_data (0x14 is x86_capability offset)
8*(0xffffffff81d69734-0xffffffff81c4eeec) => 9257536 -2 because we
want to clear the second bit. With clearcpuid=-9257534 we change the
definition of one_hundread to 96 which is used among other things
as sysfs' max value for swappiness, so we can check the effect like so:
# echo 96 > /proc/sys/vm/swappiness
# echo 97 > /proc/sys/vm/swappiness
-bash: echo: write error: Invalid argument
---
arch/x86/kernel/cpu/common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index dc1697c..9bab7a8 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1221,7 +1221,7 @@ static __init int setup_disablecpuid(char *arg)
{
int bit;
- if (get_option(&arg, &bit) && bit < NCAPINTS*32)
+ if (get_option(&arg, &bit) && bit >= 0 && bit < NCAPINTS * 32)
setup_clear_cpu_cap(bit);
else
return 0;
--
1.8.3.1
next reply other threads:[~2016-12-28 13:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-28 13:55 Lukasz Odzioba [this message]
2016-12-29 10:21 ` [PATCH 1/1] x86: sanitize argument of clearcpuid command-line option Borislav Petkov
2017-01-05 7:55 ` Ingo Molnar
2017-01-16 18:50 ` Odzioba, Lukasz
2017-01-17 7:17 ` Ingo Molnar
2017-01-18 9:52 ` Odzioba, Lukasz
2017-01-05 15:04 ` [tip:x86/urgent] x86/cpu: Fix bootup crashes by sanitizing the argument of the 'clearcpuid=' " tip-bot for Lukasz Odzioba
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=1482933340-11857-1-git-send-email-lukasz.odzioba@intel.com \
--to=lukasz.odzioba@intel.com \
--cc=andi.kleen@intel.com \
--cc=bp@alien8.de \
--cc=bp@suse.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=slaoub@gmail.com \
--cc=tglx@linutronix.de \
--cc=x86@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;
as well as URLs for NNTP newsgroup(s).