Do not allow to probe on "__cfi_" or "__pfx_" started symbol, because those are used for CFI and not executed. Probing it will break the CFI. Link: https://lore.kernel.org/all/168904024679.116016.18089228029322008512.stgit@devnote2/
Showing the changes to kernel (1 of 1 file). Show all
Unified · Split
| @@ -1545,6 +1545,17 @@ static int check_ftrace_location(struct kprobe *p) · 1544 unmodified lines | |||
| 1545 | return 0; | 1545 | return 0; |
| 1546 | } | 1546 | } |
| 1547 | 1547 | ||
| 1548 | static bool is_cfi_preamble_symbol(unsigned long addr) | ||
| 1549 | { | ||
| 1550 | char symbuf[KSYM_NAME_LEN]; | ||
| 1551 | |||
| 1552 | if (lookup_symbol_name(addr, symbuf)) | ||
| 1553 | return false; | ||
| 1554 | |||
| 1555 | return str_has_prefix("__cfi_", symbuf) || | ||
| 1556 | str_has_prefix("__pfx_", symbuf); | ||
| 1557 | } | ||
| 1558 | |||
| 1548 | static int check_kprobe_address_safe(struct kprobe *p, | 1559 | static int check_kprobe_address_safe(struct kprobe *p, |
| 1549 | struct module **probed_mod) | 1560 | struct module **probed_mod) |
| 1550 | { | 1561 | { |
| @@ -1563,7 +1574,8 @@ static int check_kprobe_address_safe(struct kprobe *p, · 12 unmodified lines | |||
| 1563 | within_kprobe_blacklist((unsigned long) p->addr) || | 1574 | within_kprobe_blacklist((unsigned long) p->addr) || |
| 1564 | jump_label_text_reserved(p->addr, p->addr) || | 1575 | jump_label_text_reserved(p->addr, p->addr) || |
| 1565 | static_call_text_reserved(p->addr, p->addr) || | 1576 | static_call_text_reserved(p->addr, p->addr) || |
| 1566 | find_bug((unsigned long)p->addr)) { | 1577 | find_bug((unsigned long)p->addr) || |
| 1578 | is_cfi_preamble_symbol((unsigned long)p->addr)) { | ||
| 1567 | ret = -EINVAL; | 1579 | ret = -EINVAL; |
| 1568 | goto out; | 1580 | goto out; |
| 1569 | } | 1581 | } |