Skip to contentSkip to conversation

arch/x86/kernel: check the return value of insn_decode_kernel()

PATCH Superseded Li Zhong 1 participant 1 message Sep 7, 2022

Subsystems (2)
lore
Share & tools
lore

Li Zhong

author
#0 lore raw

PATCH v2 1/1 arch/x86/kernel: check the return value of insn_decode_kernel()

From: lily <[email protected]>

insn_decode() could fail and the insn.length could be invalid. So we need to check the return value first.

---
 arch/x86/kernel/jump_label.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/x86/kernel/jump_label.c +3 -2
index f5b8ef02d172..59385700f579 100644
@@ -20,9 +20,10 @@
 int arch_jump_entry_size(struct jump_entry *entry)
 {
 	struct insn insn = {};
+	int ret;
 
-	insn_decode_kernel(&insn, (void *)jump_entry_code(entry));
-	BUG_ON(insn.length != 2 && insn.length != 5);
+	ret = insn_decode_kernel(&insn, (void *)jump_entry_code(entry));
+	BUG_ON(ret < 0 || (insn.length != 2 && insn.length != 5));
 
 	return insn.length;
 }
Signature · 1 line
2.25.1