Re: [PATCH 0/5 v2] [GIT PULL] x86/jump label: Paranoid checks and 2or 5 byte nops

From: Steven Rostedt
Date: Thu Feb 02 2012 - 17:04:47 EST


On Thu, 2012-02-02 at 09:31 -0500, Steven Rostedt wrote:

> This code died on "enabling" the nop. I think the code now enables some
> nops by default on boot up, which doesn't expect to see the
> "default_nop".
>

Ah, we do have jump labels that are default on. I'm still not triggering
these, I'm not sure why. Perhaps a command line difference?

Anyway, this should fix the bug:

-- Steve


Ingo,

Please pull the latest tip/perf/jump-label-4 tree, which can be found at:

git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
tip/perf/jump-label-4

Head SHA1: 7bbd9688727dd30cd44b90b3c9c35f0f66af77ff


Steven Rostedt (1):
x86/jump labels: Handle initialization of enabled nops

----
arch/x86/kernel/jump_label.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
---------------------------
commit 7bbd9688727dd30cd44b90b3c9c35f0f66af77ff
Author: Steven Rostedt <srostedt@xxxxxxxxxx>
Date: Thu Feb 2 16:55:43 2012 -0500

x86/jump labels: Handle initialization of enabled nops

When jump labels are initialized at boot up, they are compared
to the default_nop before switching to the ideal nop.

But if a jump label is enabled by default on start up, the
enabled code does not test against the default nop, only the
ideal nop. But as this jump label has not been converted to the
ideal nop, it fails the check, and will crash the box.

The enabled path needs to be aware of initialization too.

Reported-by: Ingo Molnar <mingo@xxxxxxx>
Signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>

diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c
index 2839524..d560c80 100644
--- a/arch/x86/kernel/jump_label.c
+++ b/arch/x86/kernel/jump_label.c
@@ -66,7 +66,8 @@ static void __jump_label_transform(struct jump_entry *entry,
code.jump_short = 0xeb;
code.offset = entry->target - (entry->code + 2);
/* Check for overflow ? */
- } else if (memcmp(ip, ideal_nop, 5) == 0) {
+ } else if ((!init && memcmp(ip, ideal_nop, 5) == 0) ||
+ (init && memcmp(ip, default_nop, 5) == 0)) {
size = JUMP_LABEL_NOP_SIZE;
code.jump = 0xe9;
code.offset = entry->target - (entry->code + size);

Attachment: signature.asc
Description: This is a digitally signed message part