linux-yocto/scripts
Ada Couprie Diaz 392260eb8e kasan: fix GCC mem-intrinsic prefix with sw tags
[ Upstream commit 51337a9a3a404fde0f5337662ffc7699793dfeb5 ]

GCC doesn't support "hwasan-kernel-mem-intrinsic-prefix", only
"asan-kernel-mem-intrinsic-prefix"[0], while LLVM supports both.  This is
already taken into account when checking
"CONFIG_CC_HAS_KASAN_MEMINTRINSIC_PREFIX", but not in the KASAN Makefile
adding those parameters when "CONFIG_KASAN_SW_TAGS" is enabled.

Replace the version check with "CONFIG_CC_HAS_KASAN_MEMINTRINSIC_PREFIX",
which already validates that mem-intrinsic prefix parameter can be used,
and choose the correct name depending on compiler.

GCC 13 and above trigger "CONFIG_CC_HAS_KASAN_MEMINTRINSIC_PREFIX" which
prevents `mem{cpy,move,set}()` being redefined in "mm/kasan/shadow.c"
since commit 36be5cba99 ("kasan: treat meminstrinsic as builtins in
uninstrumented files"), as we expect the compiler to prefix those calls
with `__(hw)asan_` instead.  But as the option passed to GCC has been
incorrect, the compiler has not been emitting those prefixes, effectively
never calling the instrumented versions of `mem{cpy,move,set}()` with
"CONFIG_KASAN_SW_TAGS" enabled.

If "CONFIG_FORTIFY_SOURCES" is enabled, this issue would be mitigated as
it redefines `mem{cpy,move,set}()` and properly aliases the
`__underlying_mem*()` that will be called to the instrumented versions.

Link: https://lkml.kernel.org/r/20250821120735.156244-1-ada.coupriediaz@arm.com
Link: https://gcc.gnu.org/onlinedocs/gcc-13.4.0/gcc/Optimize-Options.html [0]
Signed-off-by: Ada Couprie Diaz <ada.coupriediaz@arm.com>
Fixes: 36be5cba99 ("kasan: treat meminstrinsic as builtins in uninstrumented files")
Reviewed-by: Yeoreum Yun <yeoreum.yun@arm.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Dmitriy Vyukov <dvyukov@google.com>
Cc: Marco Elver <elver@google.com>
Cc: Marc Rutland <mark.rutland@arm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
[ kasan_params => CFLAGS_KASAN ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-09-19 16:32:01 +02:00
..
atomic locking/atomic: scripts: fix ${atomic}_sub_and_test() kerneldoc 2024-06-27 13:49:11 +02:00
basic
clang-tools gen_compile_commands: fix invalid escape sequence warning 2024-03-26 18:19:11 -04:00
coccinelle
dtc
dummy-tools
gcc-plugins randstruct: gcc-plugin: Fix attribute addition 2025-06-19 15:28:25 +02:00
gdb scripts/gdb: fix interrupts.py after maple tree conversion 2025-07-17 18:35:15 +02:00
genksyms genksyms: fix memory leak when the same symbol is read from *.symref file 2025-02-08 09:52:32 +01:00
kconfig kconfig: lxdialog: fix 'space' to (de)select options 2025-08-28 16:28:29 +02:00
ksymoops
mod modpost: fix the missed iteration for the max bit in do_input() 2025-01-09 13:32:06 +01:00
package kbuild: rpm-pkg: simplify installkernel %post 2025-07-06 11:00:16 +02:00
selinux selinux: Chain up tool resolving errors in install_policy.sh 2025-04-10 14:37:26 +02:00
tracing
.gitignore
as-version.sh
asn1_compiler.c
bloat-o-meter
bootgraph.pl
bpf_doc.py scripts/bpf_doc: Use silent mode when exec make cmd 2024-04-10 16:35:40 +02:00
cc-can-link.sh
cc-version.sh
check_extable.sh
check-git
check-sysctl-docs
checkdeclares.pl
checkincludes.pl
checkkconfigsymbols.py
checkpatch.pl checkpatch: always parse orig_commit in fixes tag 2024-12-09 10:32:18 +01:00
checkstack.pl scripts: clean up IA-64 code 2025-07-06 11:00:16 +02:00
checksyscalls.sh
checkversion.pl
cleanfile
cleanpatch
coccicheck
config kbuild: fix argument parsing in scripts/config 2025-06-04 14:41:58 +02:00
const_structs.checkpatch
decode_stacktrace.sh
decodecode
depmod.sh
dev-needs.sh
diffconfig
documentation-file-ref-check
export_report.pl
extract_xc3028.pl
extract-ikconfig
extract-module-sig.pl
extract-sys-certs.pl
extract-vmlinux
faddr2line
file-size.sh
find-unused-docs.sh
gcc-x86_32-has-stack-protector.sh kbuild: Fix '-S -c' in x86 stack protector scripts 2024-08-03 08:54:24 +02:00
gcc-x86_64-has-stack-protector.sh kbuild: Fix '-S -c' in x86 stack protector scripts 2024-08-03 08:54:24 +02:00
gen-randstruct-seed.sh
generate_initcall_order.pl
generate_rust_analyzer.py scripts: generate_rust_analyzer: add missing macros deps 2025-03-22 12:50:48 -07:00
generate_rust_target.rs
get_abi.pl
get_dvb_firmware
get_feat.pl
get_maintainer.pl
gfp-translate
head-object-list.txt scripts: clean up IA-64 code 2025-07-06 11:00:16 +02:00
headerdep.pl
headers_install.sh
insert-sys-cert.c
install.sh
jobserver-exec
kallsyms.c
Kbuild.include
Kconfig.include x86/kconfig: Add as-instr64 macro to properly evaluate AS_WRUSS 2024-08-03 08:53:21 +02:00
kernel-doc
ld-version.sh kbuild: Make ld-version.sh more robust against version string changes 2024-07-18 13:21:27 +02:00
leaking_addresses.pl
Lindent
link-vmlinux.sh kbuild: fix short log for AS in link-vmlinux.sh 2024-07-11 12:49:21 +02:00
Makefile
Makefile.asm-generic
Makefile.build kbuild: rust: force alloc extern to allow "empty" Rust files 2024-05-02 16:32:42 +02:00
Makefile.clang
Makefile.clean
Makefile.compiler kbuild: Add -Wa,--fatal-warnings to as-instr invocation 2024-03-06 14:48:41 +00:00
Makefile.debug
Makefile.defconf
Makefile.dtbinst kbuild: Install dtb files as 0644 in Makefile.dtbinst 2024-07-05 09:34:02 +02:00
Makefile.extrawarn kbuild: Disable -Wdefault-const-init-unsafe 2025-06-19 15:28:45 +02:00
Makefile.gcc-plugins
Makefile.headersinst
Makefile.host
Makefile.kasan kasan: fix GCC mem-intrinsic prefix with sw tags 2025-09-19 16:32:01 +02:00
Makefile.kcov
Makefile.kcsan
Makefile.kmsan
Makefile.lib objtool: Silence more KCOV warnings, part 2 2025-05-02 07:51:04 +02:00
Makefile.modfinal kbuild: Disable KCSAN for autogenerated *.mod.c intermediaries 2024-05-17 12:02:12 +02:00
Makefile.modinst
Makefile.modpost
Makefile.package kbuild: Fix build target deb-pkg: ln: failed to create hard link 2024-07-05 09:33:56 +02:00
Makefile.randstruct
Makefile.ubsan
Makefile.userprogs
Makefile.vdsoinst s390/vdso: Create .build-id links for unstripped vdso files 2024-06-12 11:12:33 +02:00
Makefile.vmlinux
Makefile.vmlinux_o
makelst
markup_oops.pl
min-tool-version.sh rust: upgrade to Rust 1.73.0 2024-02-16 19:10:43 +01:00
misc-check
mkcompile_h
mksysmap kallsyms: ignore ARMv4 thunks along with others 2024-02-23 09:24:59 +01:00
mkuboot.sh
module.lds.S modules: Drop the .export_symbol section from the final modules 2024-06-12 11:12:12 +02:00
modules-check.sh
nsdeps
objdiff
objdump-func
orc_hash.sh
pahole-flags.sh
pahole-version.sh
parse-maintainers.pl
patch-kernel
profile2linkerlist.pl
prune-kernel
recordmcount.c scripts: clean up IA-64 code 2025-07-06 11:00:16 +02:00
recordmcount.h
recordmcount.pl scripts: clean up IA-64 code 2025-07-06 11:00:16 +02:00
relocs_check.sh
remove-stale-files
rust_is_available_bindgen_libclang.h
rust_is_available_test.py
rust_is_available.sh rust: work around bindgen 0.69.0 issue 2024-08-29 17:33:29 +02:00
rustdoc_test_builder.rs
rustdoc_test_gen.rs
setlocalversion setlocalversion: work around "git describe" performance 2024-12-14 20:00:17 +01:00
show_delta
sign-file.c sign-file,extract-cert: use pkcs11 provider for OPENSSL MAJOR >= 3 2025-04-25 10:45:58 +02:00
sorttable.c
sorttable.h scripts/sorttable: fix orc_sort_cmp() to maintain symmetry and transitivity 2025-01-09 13:32:07 +01:00
spdxcheck-test.sh
spdxcheck.py
spdxexclude
spelling.txt
sphinx-pre-install
split-man.pl
ssl-common.h sign-file,extract-cert: avoid using deprecated ERR_get_error_line() 2025-04-25 10:45:58 +02:00
stackdelta
stackusage
subarch.include
syscallhdr.sh
syscallnr.sh
syscalltbl.sh
tags.sh
test_fortify.sh
tools-support-relr.sh
unifdef.c
ver_linux
xen-hypercalls.sh
xz_wrap.sh scripts: clean up IA-64 code 2025-07-06 11:00:16 +02:00