Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'x86_urgent_for_v6.2_rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 fixes from Borislav Petkov:

- Two fixes to correct how kprobes handles INT3 now that they're added
by other functionality like the rethunks and not only kgdb

- Remove __init section markings of two functions which are referenced
by a function in the .text section

* tag 'x86_urgent_for_v6.2_rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86/kprobes: Fix optprobe optimization check with CONFIG_RETHUNK
x86/kprobes: Fix kprobes instruction boudary check with CONFIG_RETHUNK
x86/calldepth: Fix incorrect init section references

+17 -25
+2 -2
arch/x86/kernel/callthunks.c
··· 119 119 return within_module_coretext(addr); 120 120 } 121 121 122 - static __init_or_module bool skip_addr(void *dest) 122 + static bool skip_addr(void *dest) 123 123 { 124 124 if (dest == error_entry) 125 125 return true; ··· 181 181 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 182 182 }; 183 183 184 - static __init_or_module void *patch_dest(void *dest, bool direct) 184 + static void *patch_dest(void *dest, bool direct) 185 185 { 186 186 unsigned int tsize = SKL_TMPL_SIZE; 187 187 u8 *pad = dest - tsize;
+7 -3
arch/x86/kernel/kprobes/core.c
··· 37 37 #include <linux/extable.h> 38 38 #include <linux/kdebug.h> 39 39 #include <linux/kallsyms.h> 40 + #include <linux/kgdb.h> 40 41 #include <linux/ftrace.h> 41 42 #include <linux/kasan.h> 42 43 #include <linux/moduleloader.h> ··· 282 281 if (ret < 0) 283 282 return 0; 284 283 284 + #ifdef CONFIG_KGDB 285 285 /* 286 - * Another debugging subsystem might insert this breakpoint. 287 - * In that case, we can't recover it. 286 + * If there is a dynamically installed kgdb sw breakpoint, 287 + * this function should not be probed. 288 288 */ 289 - if (insn.opcode.bytes[0] == INT3_INSN_OPCODE) 289 + if (insn.opcode.bytes[0] == INT3_INSN_OPCODE && 290 + kgdb_has_hit_break(addr)) 290 291 return 0; 292 + #endif 291 293 addr += insn.length; 292 294 } 293 295
+8 -20
arch/x86/kernel/kprobes/opt.c
··· 15 15 #include <linux/extable.h> 16 16 #include <linux/kdebug.h> 17 17 #include <linux/kallsyms.h> 18 + #include <linux/kgdb.h> 18 19 #include <linux/ftrace.h> 19 20 #include <linux/objtool.h> 20 21 #include <linux/pgtable.h> ··· 280 279 return ret; 281 280 } 282 281 283 - static bool is_padding_int3(unsigned long addr, unsigned long eaddr) 284 - { 285 - unsigned char ops; 286 - 287 - for (; addr < eaddr; addr++) { 288 - if (get_kernel_nofault(ops, (void *)addr) < 0 || 289 - ops != INT3_INSN_OPCODE) 290 - return false; 291 - } 292 - 293 - return true; 294 - } 295 - 296 282 /* Decode whole function to ensure any instructions don't jump into target */ 297 283 static int can_optimize(unsigned long paddr) 298 284 { ··· 322 334 ret = insn_decode_kernel(&insn, (void *)recovered_insn); 323 335 if (ret < 0) 324 336 return 0; 325 - 337 + #ifdef CONFIG_KGDB 326 338 /* 327 - * In the case of detecting unknown breakpoint, this could be 328 - * a padding INT3 between functions. Let's check that all the 329 - * rest of the bytes are also INT3. 339 + * If there is a dynamically installed kgdb sw breakpoint, 340 + * this function should not be probed. 330 341 */ 331 - if (insn.opcode.bytes[0] == INT3_INSN_OPCODE) 332 - return is_padding_int3(addr, paddr - offset + size) ? 1 : 0; 333 - 342 + if (insn.opcode.bytes[0] == INT3_INSN_OPCODE && 343 + kgdb_has_hit_break(addr)) 344 + return 0; 345 + #endif 334 346 /* Recover address */ 335 347 insn.kaddr = (void *)addr; 336 348 insn.next_byte = (void *)(addr + insn.length);