mirror of
https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux
synced 2025-09-18 10:41:49 +10:00
- Use RCU instead of RCU-sched
The mix of rcu_read_lock(), rcu_read_lock_sched() and preempt_disable()
in the module code and its users has been replaced with just
rcu_read_lock().
- The rest of changes are smaller fixes and updates.
The changes have been on linux-next for at least 2 weeks, with the RCU
cleanup present for 2 months. One performance problem was reported with the
RCU change when KASAN + lockdep were enabled, but it was effectively
addressed by the already merged ee57ab5a32
("locking/lockdep: Disable
KASAN instrumentation of lockdep.c").
-----BEGIN PGP SIGNATURE-----
iQFIBAABCAAyFiEEIduBR9MnFA82q/jtumpXJwqY6poFAmfmwrsUHHBldHIucGF2
bHVAc3VzZS5jb20ACgkQumpXJwqY6prWxgf/S7Pvdywm10vJ6fooYa+GxXNMwhyh
XRjZ4m9gjeTNf2KLwX0XHv0XZeFHOmHfjd3iI+pS6CXZnCFTN9J3XPLYsrTxXUb6
U6zzLf8Zsz8TzeI4dgvSBsZln7oICSACkAgdJCq23hpNKeaeRo91dgiZaIwyZJG3
FekqSFtP7pYhfFoNkrFKysqbgl1+RWWZ79L2qRJA0bPzVFlvRUuh6cOHQw+8RMqf
BYLwnArjTkW8AcXpxIXSiwphDHVZ81B96xoplavyoprA5FDpv1W+8y4DtxdWFn+1
QVWCs/ZV3KrwXWpZev625w3fIOOIXILqRINOzLfvXTw+1xFS3TzSQEpVeg==
=4OKc
-----END PGP SIGNATURE-----
Merge tag 'modules-6.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/modules/linux
Pull modules updates from Petr Pavlu:
- Use RCU instead of RCU-sched
The mix of rcu_read_lock(), rcu_read_lock_sched() and
preempt_disable() in the module code and its users has
been replaced with just rcu_read_lock()
- The rest of changes are smaller fixes and updates
* tag 'modules-6.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/modules/linux: (32 commits)
MAINTAINERS: Update the MODULE SUPPORT section
module: Remove unnecessary size argument when calling strscpy()
module: Replace deprecated strncpy() with strscpy()
params: Annotate struct module_param_attrs with __counted_by()
bug: Use RCU instead RCU-sched to protect module_bug_list.
static_call: Use RCU in all users of __module_text_address().
kprobes: Use RCU in all users of __module_text_address().
bpf: Use RCU in all users of __module_text_address().
jump_label: Use RCU in all users of __module_text_address().
jump_label: Use RCU in all users of __module_address().
x86: Use RCU in all users of __module_address().
cfi: Use RCU while invoking __module_address().
powerpc/ftrace: Use RCU in all users of __module_text_address().
LoongArch: ftrace: Use RCU in all users of __module_text_address().
LoongArch/orc: Use RCU in all users of __module_address().
arm64: module: Use RCU in all users of __module_text_address().
ARM: module: Use RCU in all users of __module_text_address().
module: Use RCU in all users of __module_text_address().
module: Use RCU in all users of __module_address().
module: Use RCU in search_module_extables().
...
101 lines
2.2 KiB
C
101 lines
2.2 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Clang Control Flow Integrity (CFI) error handling.
|
|
*
|
|
* Copyright (C) 2022 Google LLC
|
|
*/
|
|
|
|
#include <linux/cfi.h>
|
|
|
|
bool cfi_warn __ro_after_init = IS_ENABLED(CONFIG_CFI_PERMISSIVE);
|
|
|
|
enum bug_trap_type report_cfi_failure(struct pt_regs *regs, unsigned long addr,
|
|
unsigned long *target, u32 type)
|
|
{
|
|
if (target)
|
|
pr_err("CFI failure at %pS (target: %pS; expected type: 0x%08x)\n",
|
|
(void *)addr, (void *)*target, type);
|
|
else
|
|
pr_err("CFI failure at %pS (no target information)\n",
|
|
(void *)addr);
|
|
|
|
if (cfi_warn) {
|
|
__warn(NULL, 0, (void *)addr, 0, regs, NULL);
|
|
return BUG_TRAP_TYPE_WARN;
|
|
}
|
|
|
|
return BUG_TRAP_TYPE_BUG;
|
|
}
|
|
|
|
#ifdef CONFIG_ARCH_USES_CFI_TRAPS
|
|
static inline unsigned long trap_address(s32 *p)
|
|
{
|
|
return (unsigned long)((long)p + (long)*p);
|
|
}
|
|
|
|
static bool is_trap(unsigned long addr, s32 *start, s32 *end)
|
|
{
|
|
s32 *p;
|
|
|
|
for (p = start; p < end; ++p) {
|
|
if (trap_address(p) == addr)
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
#ifdef CONFIG_MODULES
|
|
/* Populates `kcfi_trap(_end)?` fields in `struct module`. */
|
|
void module_cfi_finalize(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs,
|
|
struct module *mod)
|
|
{
|
|
char *secstrings;
|
|
unsigned int i;
|
|
|
|
mod->kcfi_traps = NULL;
|
|
mod->kcfi_traps_end = NULL;
|
|
|
|
secstrings = (char *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
|
|
|
|
for (i = 1; i < hdr->e_shnum; i++) {
|
|
if (strcmp(secstrings + sechdrs[i].sh_name, "__kcfi_traps"))
|
|
continue;
|
|
|
|
mod->kcfi_traps = (s32 *)sechdrs[i].sh_addr;
|
|
mod->kcfi_traps_end = (s32 *)(sechdrs[i].sh_addr + sechdrs[i].sh_size);
|
|
break;
|
|
}
|
|
}
|
|
|
|
static bool is_module_cfi_trap(unsigned long addr)
|
|
{
|
|
struct module *mod;
|
|
bool found = false;
|
|
|
|
guard(rcu)();
|
|
mod = __module_address(addr);
|
|
if (mod)
|
|
found = is_trap(addr, mod->kcfi_traps, mod->kcfi_traps_end);
|
|
|
|
return found;
|
|
}
|
|
#else /* CONFIG_MODULES */
|
|
static inline bool is_module_cfi_trap(unsigned long addr)
|
|
{
|
|
return false;
|
|
}
|
|
#endif /* CONFIG_MODULES */
|
|
|
|
extern s32 __start___kcfi_traps[];
|
|
extern s32 __stop___kcfi_traps[];
|
|
|
|
bool is_cfi_trap(unsigned long addr)
|
|
{
|
|
if (is_trap(addr, __start___kcfi_traps, __stop___kcfi_traps))
|
|
return true;
|
|
|
|
return is_module_cfi_trap(addr);
|
|
}
|
|
#endif /* CONFIG_ARCH_USES_CFI_TRAPS */
|