Patch "x86/kprobes: Fix to check non boostable prefixes correctly" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    x86/kprobes: Fix to check non boostable prefixes correctly

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     x86-kprobes-fix-to-check-non-boostable-prefixes-corr.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit dd52d0b3271733b7ac7854c545abdb4931f386a6
Author: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
Date:   Thu Mar 25 19:08:31 2021 +0900

    x86/kprobes: Fix to check non boostable prefixes correctly
    
    [ Upstream commit 6dd3b8c9f58816a1354be39559f630cd1bd12159 ]
    
    There are 2 bugs in the can_boost() function because of using
    x86 insn decoder. Since the insn->opcode never has a prefix byte,
    it can not find CS override prefix in it. And the insn->attr is
    the attribute of the opcode, thus inat_is_address_size_prefix(
    insn->attr) always returns false.
    
    Fix those by checking each prefix bytes with for_each_insn_prefix
    loop and getting the correct attribute for each prefix byte.
    Also, this removes unlikely, because this is a slow path.
    
    Fixes: a8d11cd0714f ("kprobes/x86: Consolidate insn decoder users for copying code")
    Signed-off-by: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
    Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/161666691162.1120877.2808435205294352583.stgit@devnote2
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
index 39f7d8c3c064..535da74c124e 100644
--- a/arch/x86/kernel/kprobes/core.c
+++ b/arch/x86/kernel/kprobes/core.c
@@ -159,6 +159,8 @@ NOKPROBE_SYMBOL(skip_prefixes);
 int can_boost(struct insn *insn, void *addr)
 {
 	kprobe_opcode_t opcode;
+	insn_byte_t prefix;
+	int i;
 
 	if (search_exception_tables((unsigned long)addr))
 		return 0;	/* Page fault may occur on this address. */
@@ -171,9 +173,14 @@ int can_boost(struct insn *insn, void *addr)
 	if (insn->opcode.nbytes != 1)
 		return 0;
 
-	/* Can't boost Address-size override prefix */
-	if (unlikely(inat_is_address_size_prefix(insn->attr)))
-		return 0;
+	for_each_insn_prefix(insn, i, prefix) {
+		insn_attr_t attr;
+
+		attr = inat_get_opcode_attribute(prefix);
+		/* Can't boost Address-size override prefix and CS override prefix */
+		if (prefix == 0x2e || inat_is_address_size_prefix(attr))
+			return 0;
+	}
 
 	opcode = insn->opcode.bytes[0];
 
@@ -198,8 +205,8 @@ int can_boost(struct insn *insn, void *addr)
 		/* clear and set flags are boostable */
 		return (opcode == 0xf5 || (0xf7 < opcode && opcode < 0xfe));
 	default:
-		/* CS override prefix and call are not boostable */
-		return (opcode != 0x2e && opcode != 0x9a);
+		/* call is not boostable */
+		return opcode != 0x9a;
 	}
 }
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux