Skip to content

Commit 14c4c8e

Browse files
eberman-quickees
authored andcommitted
cfi: Use rcu_read_{un}lock_sched_notrace
If rcu_read_lock_sched tracing is enabled, the tracing subsystem can perform a jump which needs to be checked by CFI. For example, stm_ftrace source is enabled as a module and hooks into enabled ftrace events. This can cause an recursive loop where find_shadow_check_fn -> rcu_read_lock_sched -> (call to stm_ftrace generates cfi slowpath) -> find_shadow_check_fn -> rcu_read_lock_sched -> ... To avoid the recursion, either the ftrace codes needs to be marked with __no_cfi or CFI should not trace. Use the "_notrace" in CFI to avoid tracing so that CFI can guard ftrace. Signed-off-by: Elliot Berman <[email protected]> Reviewed-by: Sami Tolvanen <[email protected]> Cc: [email protected] Fixes: cf68fff ("add support for Clang CFI") Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 36a21d5 commit 14c4c8e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

kernel/cfi.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,9 @@ static inline cfi_check_fn find_shadow_check_fn(unsigned long ptr)
248248
{
249249
cfi_check_fn fn;
250250

251-
rcu_read_lock_sched();
251+
rcu_read_lock_sched_notrace();
252252
fn = ptr_to_check_fn(rcu_dereference_sched(cfi_shadow), ptr);
253-
rcu_read_unlock_sched();
253+
rcu_read_unlock_sched_notrace();
254254

255255
return fn;
256256
}
@@ -269,11 +269,11 @@ static inline cfi_check_fn find_module_check_fn(unsigned long ptr)
269269
cfi_check_fn fn = NULL;
270270
struct module *mod;
271271

272-
rcu_read_lock_sched();
272+
rcu_read_lock_sched_notrace();
273273
mod = __module_address(ptr);
274274
if (mod)
275275
fn = mod->cfi_check;
276-
rcu_read_unlock_sched();
276+
rcu_read_unlock_sched_notrace();
277277

278278
return fn;
279279
}

0 commit comments

Comments
 (0)