Skip to contentSkip to conversation

uprobes/x86: allow to probe a "nop" insn with 0x66 prefix

PATCH Superseded Oleg Nesterov 4 participants 7 messages Dec 1, 2022 – Dec 5, 2022

Subsystems (2)
lore
Share & tools
lore

Oleg Nesterov

author maintainer
#0 lore raw

PATCH 1/1 uprobes/x86: allow to probe a "nop" insn with 0x66 prefix

From: Denys Vlasenko <[email protected]>

Intel icc -hotpatch inserts 2-byte "0x66 0x90" NOP at the start of each function to reserve extra space for hot-patching, and currently it is not possible to probe these functions because branch_setup_xol_ops() wrongly nacks NOP with REP prefix.

Fixes 250bbd12c2fe ("uprobes/x86: Refuse to attach uprobe to "word-sized" branch insns")
---
 arch/x86/kernel/uprobes.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kernel/uprobes.c +3 -1
index b63cf8f7745e..6c07f6daaa22 100644
@@ -722,8 +722,9 @@ static int branch_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn)
 	switch (opc1) {
 	case 0xeb:	/* jmp 8 */
 	case 0xe9:	/* jmp 32 */
-	case 0x90:	/* prefix* + nop; same as jmp with .offs = 0 */
 		break;
+	case 0x90:	/* prefix* + nop; same as jmp with .offs = 0 */
+		goto setup;
 
 	case 0xe8:	/* call relative */
 		branch_clear_offset(auprobe, insn);
@@ -753,6 +754,7 @@ static int branch_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn)
 			return -ENOTSUPP;
 	}
 
+setup:
 	auprobe->branch.opc1 = opc1;
 	auprobe->branch.ilen = insn->length;
 	auprobe->branch.offs = insn->immediate.value;
Signature · 1 line
2.25.1.362.g51ebf55
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · On Thu, 1 Dec 2022 15:26:44 +0100 Oleg Nesterov <[email protected]> wrote:

From: Denys Vlasenko <[email protected]>

Intel icc -hotpatch inserts 2-byte "0x66 0x90" NOP at the start of each function to reserve extra space for hot-patching, and currently it is not possible to probe these functions because branch_setup_xol_ops() wrongly nacks NOP with REP prefix.

Looks good to me.

Thank you!

Quoted 35 lines
Fixes 250bbd12c2fe ("uprobes/x86: Refuse to attach uprobe to "word-sized" branch insns")
---
 arch/x86/kernel/uprobes.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kernel/uprobes.c +3 -1
index b63cf8f7745e..6c07f6daaa22 100644
@@ -722,8 +722,9 @@ static int branch_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn)
 	switch (opc1) {
 	case 0xeb:	/* jmp 8 */
 	case 0xe9:	/* jmp 32 */
-	case 0x90:	/* prefix* + nop; same as jmp with .offs = 0 */
 		break;
+	case 0x90:	/* prefix* + nop; same as jmp with .offs = 0 */
+		goto setup;
 
 	case 0xe8:	/* call relative */
 		branch_clear_offset(auprobe, insn);
@@ -753,6 +754,7 @@ static int branch_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn)
 			return -ENOTSUPP;
 	}
 
+setup:
 	auprobe->branch.opc1 = opc1;
 	auprobe->branch.ilen = insn->length;
 	auprobe->branch.offs = insn->immediate.value;
Signature · 1 line
2.25.1.362.g51ebf55
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
#2 lore raw
In reply to Oleg Nesterov
Quoted 10 lines · Oleg Nesterov

From: Denys Vlasenko <[email protected]>

Intel icc -hotpatch inserts 2-byte "0x66 0x90" NOP at the start of each function to reserve extra space for hot-patching, and currently it is not possible to probe these functions because branch_setup_xol_ops() wrongly nacks NOP with REP prefix.

Fixes 250bbd12c2fe ("uprobes/x86: Refuse to attach uprobe to "word-sized" branch insns")

The SOB chain is invalid as it lacks the author's signoff.

author maintainer
#3 lore raw
Quoted 10 lines · Thomas Gleixner
Quoted 7 lines · Oleg Nesterov

From: Denys Vlasenko <[email protected]>

Intel icc -hotpatch inserts 2-byte "0x66 0x90" NOP at the start of each function to reserve extra space for hot-patching, and currently it is not possible to probe these functions because branch_setup_xol_ops() wrongly nacks NOP with REP prefix.

Quoted 5 lines
Quoted 3 lines
Fixes 250bbd12c2fe ("uprobes/x86: Refuse to attach uprobe to "word-sized" branch insns")

The SOB chain is invalid as it lacks the author's signoff.

Denys, can we have your signed-off-by?

author maintainer
#4 lore raw
Quoted 12 lines · Oleg Nesterov
Quoted 10 lines · Thomas Gleixner
Quoted 7 lines · Oleg Nesterov

From: Denys Vlasenko <[email protected]>

Intel icc -hotpatch inserts 2-byte "0x66 0x90" NOP at the start of each function to reserve extra space for hot-patching, and currently it is not possible to probe these functions because branch_setup_xol_ops() wrongly nacks NOP with REP prefix.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Fixes 250bbd12c2fe ("uprobes/x86: Refuse to attach uprobe to "word-sized" branch insns")

The SOB chain is invalid as it lacks the author's signoff.

Denys, can we have your signed-off-by?

OK, let me turn "From" into "Suggested-by" if this can help to merge this fix.

After all, the patch is really simple, I don't think Denys will object when he returns.

I am sending v2 with Masami's ack applied.

Oleg.

author maintainer
#5 lore raw

PATCH v2 1/1 uprobes/x86: allow to probe a "nop" insn with 0x66 prefix

In reply to Oleg Nesterov

Intel icc -hotpatch inserts 2-byte "0x66 0x90" NOP at the start of each function to reserve extra space for hot-patching, and currently it is not possible to probe these functions because branch_setup_xol_ops() wrongly nacks NOP with REP prefix.

Fixes 250bbd12c2fe ("uprobes/x86: Refuse to attach uprobe to "word-sized" branch insns")
---
 arch/x86/kernel/uprobes.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kernel/uprobes.c +3 -1
index b63cf8f7745e..6c07f6daaa22 100644
@@ -722,8 +722,9 @@ static int branch_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn)
 	switch (opc1) {
 	case 0xeb:	/* jmp 8 */
 	case 0xe9:	/* jmp 32 */
-	case 0x90:	/* prefix* + nop; same as jmp with .offs = 0 */
 		break;
+	case 0x90:	/* prefix* + nop; same as jmp with .offs = 0 */
+		goto setup;
 
 	case 0xe8:	/* call relative */
 		branch_clear_offset(auprobe, insn);
@@ -753,6 +754,7 @@ static int branch_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn)
 			return -ENOTSUPP;
 	}
 
+setup:
 	auprobe->branch.opc1 = opc1;
 	auprobe->branch.ilen = insn->length;
 	auprobe->branch.offs = insn->immediate.value;
Signature · 1 line
2.25.1.362.g51ebf55
merge bot Applied
#6 lore raw

[tip: x86/urgent] uprobes/x86: Allow to probe a NOP instruction with 0x66 prefix

The following commit has been merged into the x86/urgent branch of tip:

The following commit has been merged into the x86/urgent branch of tip:

Commit-ID:     cefa72129e45313655d53a065b8055aaeb01a0c9
Gitweb:        https://git.kernel.org/tip/cefa72129e45313655d53a065b8055aaeb01a0c9
Author:        Oleg Nesterov <[email protected]>
AuthorDate:    Sun, 04 Dec 2022 18:39:33 +01:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Mon, 05 Dec 2022 11:55:18 +01:00

uprobes/x86: Allow to probe a NOP instruction with 0x66 prefix

Intel ICC -hotpatch inserts 2-byte "0x66 0x90" NOP at the start of each function to reserve extra space for hot-patching, and currently it is not possible to probe these functions because branch_setup_xol_ops() wrongly rejects NOP with REP prefix as it treats them like word-sized branch instructions.

---
 arch/x86/kernel/uprobes.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kernel/uprobes.c +3 -1
index b63cf8f..6c07f6d 100644
@@ -722,8 +722,9 @@ static int branch_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn)
 	switch (opc1) {
 	case 0xeb:	/* jmp 8 */
 	case 0xe9:	/* jmp 32 */
-	case 0x90:	/* prefix* + nop; same as jmp with .offs = 0 */
 		break;
+	case 0x90:	/* prefix* + nop; same as jmp with .offs = 0 */
+		goto setup;
 
 	case 0xe8:	/* call relative */
 		branch_clear_offset(auprobe, insn);
@@ -753,6 +754,7 @@ static int branch_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn)
 			return -ENOTSUPP;
 	}
 
+setup:
 	auprobe->branch.opc1 = opc1;
 	auprobe->branch.ilen = insn->length;
 	auprobe->branch.offs = insn->immediate.value;