]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
cfi: Use rcu_read_{un}lock_sched_notrace
authorElliot Berman <quic_eberman@quicinc.com>
Wed, 11 Aug 2021 15:59:14 +0000 (08:59 -0700)
committerSasha Levin <sashal@kernel.org>
Thu, 26 Aug 2021 12:35:13 +0000 (08:35 -0400)
commit8681e95da50b129619c7f57c89c2d9b719331b8a
treee20a021a7d47b0a042794238b1e664d96358c76a
parent82d1ea87b9d57434bc534fcbc7844a1112be3c8e
cfi: Use rcu_read_{un}lock_sched_notrace

[ Upstream commit 14c4c8e41511aa8fba7fb239b20b6539b5bce201 ]

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 <quic_eberman@quicinc.com>
Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Cc: stable@vger.kernel.org
Fixes: cf68fffb66d6 ("add support for Clang CFI")
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20210811155914.19550-1-quic_eberman@quicinc.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/cfi.c