Skip to contentSkip to conversation

x86/oprofile: fix wrapping bug in op_x86_get_ctrl()

PATCH In review Dan Carpenter 3 participants 4 messages Oct 10, 2012 – Oct 21, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/oprofile: fix wrapping bug in op_x86_get_ctrl()

The "event" variable is a u16 so the shift will always wrap to zero making the line a no-op.

---
This was introduced in 2009 in 3370d35856 "x86/oprofile: replace macros to calculate control register". I am doing static analysis and I'm not very familiar with this code. Please review my changes carefully.

arch/x86/oprofile/nmi_int.c +1 -1
index 26b8a85..48768df 100644
@@ -55,7 +55,7 @@ u64 op_x86_get_ctrl(struct op_x86_model_spec const *model,
 	val |= counter_config->extra;
 	event &= model->event_mask ? model->event_mask : 0xFF;
 	val |= event & 0xFF;
-	val |= (event & 0x0F00) << 24;
+	val |= (u64)(event & 0x0F00) << 24;
 
 	return val;
 }
#1 lore raw
Quoted 4 lines · Dan Carpenter

The "event" variable is a u16 so the shift will always wrap to zero making the line a no-op.

Patch applied. Thanks for reporting and fixing.

-Robert

Signature · 2 lines
Advanced Micro Devices, Inc.
Operating System Research Center
#2 lore raw

[GIT PULL] oprofile fixes

Ingo,

Quoted 7 lines · Robert Richter
Quoted 4 lines · Dan Carpenter

The "event" variable is a u16 so the shift will always wrap to zero making the line a no-op.

Patch applied. Thanks for reporting and fixing.

please pull this fix for tip:perf/urgent from

git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile.git urgent

Thanks,

-Robert

The following changes since commit ddffeb8c4d0331609ef2581d84de4d763607bd37:

Linux 3.7-rc1 (2012-10-14 14:41:04 -0700)

are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile.git urgent

Dan Carpenter (1):
oprofile, x86: Fix wrapping bug in op_x86_get_ctrl()

 arch/x86/oprofile/nmi_int.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Signature · 2 lines
Advanced Micro Devices, Inc.
Operating System Research Center
#3 lore raw

Re: [GIT PULL] oprofile fixes

Quoted 7 lines · Robert Richter

Ingo,

Quoted 4 lines · Robert Richter
Quoted 3 lines · Dan Carpenter

The "event" variable is a u16 so the shift will always wrap to zero making the line a no-op.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Patch applied. Thanks for reporting and fixing.

please pull this fix for tip:perf/urgent from

git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile.git urgent

Pulled, thanks guys!

Ingo