Commit 1703abb
kprobes: Reduce preempt disable scope in check_kprobe_access_safe()
Commit a189d03 ("kprobes: disable preempt for module_text_address() and kernel_text_address()")
introduced a preempt_disable() region to protect against concurrent
module unloading. However this region also includes the call to
jump_label_text_reserved() which takes a long time;
up to 400us, iterating over approx 6000 jump tables.
The scope protected by preempt_disable() is largen than necessary.
core_kernel_text() does not need to be protected as it does not interact
with module code at all.
Only the scope from __module_text_address() to try_module_get() needs to
be protected.
By limiting the critical section to __module_text_address() and
try_module_get() the function responsible for the latency spike remains
preemptible.
This works fine even when !CONFIG_MODULES as in that case
try_module_get() will always return true and that block can be optimized
away.
Limit the critical section to __module_text_address() and
try_module_get(). Use guard(preempt)() for easier error handling.
While at it also remove a spurious *probed_mod = NULL in an error
path. On errors the output parameter is never inspected by the caller.
Some error paths were clearing the parameters, some didn't.
Align them for clarity.
Link: https://lore.kernel.org/all/20241121-kprobes-preempt-v1-1-fd581ee7fcbb@linutronix.de/
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>1 parent 30c8fd3 commit 1703abb
1 file changed
Lines changed: 12 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
1566 | 1567 | | |
1567 | 1568 | | |
1568 | 1569 | | |
1569 | | - | |
1570 | 1570 | | |
1571 | 1571 | | |
1572 | 1572 | | |
1573 | 1573 | | |
| 1574 | + | |
1574 | 1575 | | |
1575 | 1576 | | |
1576 | 1577 | | |
1577 | 1578 | | |
1578 | 1579 | | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
1579 | 1589 | | |
1580 | 1590 | | |
1581 | 1591 | | |
| |||
1584 | 1594 | | |
1585 | 1595 | | |
1586 | 1596 | | |
| 1597 | + | |
1587 | 1598 | | |
1588 | 1599 | | |
1589 | 1600 | | |
1590 | 1601 | | |
1591 | 1602 | | |
1592 | 1603 | | |
1593 | | - | |
1594 | | - | |
1595 | | - | |
1596 | | - | |
1597 | | - | |
1598 | | - | |
1599 | | - | |
1600 | | - | |
1601 | | - | |
1602 | 1604 | | |
1603 | 1605 | | |
1604 | 1606 | | |
1605 | 1607 | | |
1606 | 1608 | | |
1607 | 1609 | | |
1608 | 1610 | | |
1609 | | - | |
1610 | 1611 | | |
1611 | 1612 | | |
1612 | 1613 | | |
1613 | 1614 | | |
1614 | 1615 | | |
1615 | | - | |
1616 | 1616 | | |
1617 | 1617 | | |
1618 | 1618 | | |
| |||
0 commit comments