lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 18 May 2015 14:21:00 -0400
From:	Prarit Bhargava <prarit@...hat.com>
To:	linux-kernel@...r.kernel.org
Cc:	Prarit Bhargava <prarit@...hat.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...hat.com>,
	"H. Peter Anvin" <hpa@...or.com>, x86@...nel.org,
	Andy Lutomirski <luto@...capital.net>,
	Borislav Petkov <bp@...en8.de>,
	Denys Vlasenko <dvlasenk@...hat.com>,
	Dave Hansen <dave.hansen@...ux.intel.com>,
	Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@...el.com>,
	Igor Mammedov <imammedo@...hat.com>,
	Fenghua Yu <fenghua.yu@...el.com>
Subject: [PATCH] x86, cpuinfo fix cpu_data(0) x86_model_id field truncation

When comparing 'model name' fields in /proc/cpuinfo it was noticed that
a simple test comparing the model name fields was failing.  After some
simple investigation it was noticed that, in fact, the model name fields
are different for each processor.  Processor 0's model name field had
white space removed, while the other processors did not.

Another way of seeing this behaviour is to convert spaces into underscores
in the output of /proc/cpuinfo,

[thetango@...rit ~]# grep "^model name" /proc/cpuinfo | uniq -c | sed 's/\ /_/g'
______1_model_name      :_AMD_Opteron(TM)_Processor_6272
_____63_model_name      :_AMD_Opteron(TM)_Processor_6272_________________

which shows two different model name fields even though they should be the
same.

This occurs because the kernel calls strim() on cpu 0's x86_model_id field
to output a pretty message to the console in print_cpu_info(), and as a
result truncates the whitespace at the end of the x86_model_id field.

The x86_model_id field should be the same for the same processors.  This
patch adds a local copy of the x86_model_id field and modifies the value
there so that the output in dmesg still looks like

smpboot: CPU0: AMD Opteron(TM) Processor 6272 (fam: 15, model: 01, stepping: 02)

and the x86_model_id field is correct across all processors:

[thetango@...rit ~]# grep "^model name" /proc/cpuinfo | uniq -c | sed 's/\ /_/g'
_____64_model_name      :_AMD_Opteron(TM)_Processor_6272_________________

Signed-off-by: Prarit Bhargava <prarit@...hat.com>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Ingo Molnar <mingo@...hat.com>
Cc: "H. Peter Anvin" <hpa@...or.com>
Cc: x86@...nel.org
Cc: Andy Lutomirski <luto@...capital.net>
Cc: Borislav Petkov <bp@...en8.de>
Cc: Denys Vlasenko <dvlasenk@...hat.com>
Cc: Dave Hansen <dave.hansen@...ux.intel.com>
Cc: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@...el.com>
Cc: Igor Mammedov <imammedo@...hat.com>
Cc: Fenghua Yu <fenghua.yu@...el.com>
---
 arch/x86/kernel/cpu/common.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index a62cf04..61ac5c3 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1110,6 +1110,7 @@ __setup("noclflush", setup_noclflush);
 void print_cpu_info(struct cpuinfo_x86 *c)
 {
 	const char *vendor = NULL;
+	char x86_model_id[64];
 
 	if (c->x86_vendor < X86_VENDOR_NUM) {
 		vendor = this_cpu->c_vendor;
@@ -1121,9 +1122,10 @@ void print_cpu_info(struct cpuinfo_x86 *c)
 	if (vendor && !strstr(c->x86_model_id, vendor))
 		printk(KERN_CONT "%s ", vendor);
 
-	if (c->x86_model_id[0])
-		printk(KERN_CONT "%s", strim(c->x86_model_id));
-	else
+	if (c->x86_model_id[0]) {
+		strcpy(x86_model_id, c->x86_model_id);
+		printk(KERN_CONT "%s", strim(x86_model_id));
+	} else
 		printk(KERN_CONT "%d86", c->x86);
 
 	printk(KERN_CONT " (fam: %02x, model: %02x", c->x86, c->x86_model);
-- 
1.7.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ