x86/kprobes: Remove dead code
Subsystems (2)
PATCH 1/1 x86/kprobes: Remove dead code
The condition in switch statement opcode & 0xf0 cannot evaluate to 0xff. So this case statement will never execute. Remove it.
--- arch/x86/kernel/kprobes/core.c | 3 --- 1 file changed, 3 deletions(-)
arch/x86/kernel/kprobes/core.c +0 -3
@@ -177,9 +177,6 @@ int can_boost(struct insn *insn, void *addr)case 0xf0 :/* clear and set flags are boostable */ return (opcode ==0xf5 || (0xf7 < opcode && opcode <0xfe )); -case 0xff : -/* indirect jmp is boostable */ -return X86_MODRM_REG (insn->modrm.bytes[0 ]) ==4 ;default :/* CS override prefix and call are not boostable */ return (opcode !=0x2e && opcode !=0x9a );
Signature · 1 line
2.25.1
Quoted 15 lines · Muhammad Usama Anjum
The condition in switch statement
opcode & 0xf0cannot evaluate to0xff. So this case statement will never execute. Remove it.Fixes 6256e668b7 ("x86/kprobes: Use int3 instead of debug trap for single-step")Signed-off-by Muhammad Usama Anjum <[email protected]>--- arch/x86/kernel/kprobes/core.c | 3 --- 1 file changed, 3 deletions(-)arch/x86/kernel/kprobes/core.c +0
-0
arch/x86/kernel/kprobes/core.c int can_boost(struct insn *insn, void *addr) · line 182
Quoted 9 lines
arch/x86/kernel/kprobes/core.c +0
-3@@ -177,9 +177,6 @@ int can_boost(struct insn *insn, void *addr)case 0xf0 :/* clear and set flags are boostable */ return (opcode ==0xf5 || (0xf7 < opcode && opcode <0xfe )); -case 0xff : -/* indirect jmp is boostable */ -return X86_MODRM_REG (insn->modrm.bytes[0 ]) ==4 ;default :/* CS override prefix and call are not boostable */ return (opcode !=0x2e && opcode !=0x9a );
The 0xff case was added with some form of intention to be executed so I suspect removing it is not an appropriate fix.
Quoted 20 lines · On Wed, 24 Mar 2021 17:50:16 +0000 Colin Ian King <[email protected]>…
Quoted 19 lines · Muhammad Usama Anjum
The condition in switch statement
opcode & 0xf0cannot evaluate to0xff. So this case statement will never execute. Remove it.Fixes 6256e668b7 ("x86/kprobes: Use int3 instead of debug trap for single-step")Signed-off-by Muhammad Usama Anjum <[email protected]>--- arch/x86/kernel/kprobes/core.c | 3 --- 1 file changed, 3 deletions(-)arch/x86/kernel/kprobes/core.c +0
-2@@ -177,9 +177,6 @@ int can_boost(struct insn *insn, void *addr)case 0xf0 :/* clear and set flags are boostable */ return (opcode ==0xf5 || (0xf7 < opcode && opcode <0xfe )); -case 0xff : -/* indirect jmp is boostable */
Quoted 8 lines
arch/x86/kernel/kprobes/core.c int can_boost(struct insn *insn, void *addr) · line 182
Quoted 5 lines
arch/x86/kernel/kprobes/core.c +0
-1-return X86_MODRM_REG (insn->modrm.bytes[0 ]) ==4 ;default :/* CS override prefix and call are not boostable */ return (opcode !=0x2e && opcode !=0x9a );The
0xffcase was added with some form of intention to be executed so I suspect removing it is not an appropriate fix.
Right, it must be moved under the case 0xf0. Something like this.
case 0xf0:
if (opcde == 0xff) {
/* indirect jmp is boostable */
return X86_MODRM_REG(insn->modrm.bytes[0]) == 4;
}Thank you,
Signature · 1 line
Masami Hiramatsu <[email protected]>
Quoted 32 lines · On Thu, 25 Mar 2021 07:56:54 +0900 Masami Hiramatsu <[email protected]> wrote:
Quoted 20 lines · On Wed, 24 Mar 2021 17:50:16 +0000 Colin Ian King <[email protected]>…
Quoted 19 lines · Muhammad Usama Anjum
The condition in switch statement
opcode & 0xf0cannot evaluate to0xff. So this case statement will never execute. Remove it.Fixes 6256e668b7 ("x86/kprobes: Use int3 instead of debug trap for single-step")Signed-off-by Muhammad Usama Anjum <[email protected]>--- arch/x86/kernel/kprobes/core.c | 3 --- 1 file changed, 3 deletions(-)arch/x86/kernel/kprobes/core.c +0
-2@@ -177,9 +177,6 @@ int can_boost(struct insn *insn, void *addr)case 0xf0 :/* clear and set flags are boostable */ return (opcode ==0xf5 || (0xf7 < opcode && opcode <0xfe )); -case 0xff : -/* indirect jmp is boostable */ Quoted 8 lines
arch/x86/kernel/kprobes/core.c int can_boost(struct insn *insn, void *addr) · line 182
Quoted 5 lines
arch/x86/kernel/kprobes/core.c +0
-1-return X86_MODRM_REG (insn->modrm.bytes[0 ]) ==4 ;default :/* CS override prefix and call are not boostable */ return (opcode !=0x2e && opcode !=0x9a );The
0xffcase was added with some form of intention to be executed so I suspect removing it is not an appropriate fix.
Quoted 7 lines
Right, it must be moved under the case
0xf0. Something like this.case
0xf0:if (opcde == 0xff) { /* indirect jmp is boostable */ return X86_MODRM_REG(insn->modrm.bytes[0]) == 4; }
Hmm, wait. I think there is no reason don't use range case. I think the root cause of this issue is using masked opcode for switching. Let me clean it up.
Thank you,
Signature · 1 line
Masami Hiramatsu <[email protected]>