Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 23 Apr 2023 19:00:42 GMT
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 42162fb2fe30 - main - kcsan: add __tsan_mem(cpy|move|set) aliases for clang >= 16
Message-ID:  <202304231900.33NJ0gvq037610@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=42162fb2fe30c0881e7e4d2143ddcfee3e1dd752

commit 42162fb2fe30c0881e7e4d2143ddcfee3e1dd752
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2023-04-23 18:11:34 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-04-23 18:59:06 +0000

    kcsan: add __tsan_mem(cpy|move|set) aliases for clang >= 16
    
    Summary:
    After https://github.com/llvm/llvm-project/commit/b4257d3bf58c ("[tsan]
    Replace mem intrinsics with calls to interceptors") intrinsic calls to
    memcpy, memmove or memset will directly call sanitizer interceptors,
    e.g. __tsan_memcpy, __tsan_memmove or __tsan_memset.
    
    Building GENERIC-KCSAN with clang >= 16 would thus result in link errors
    similar to:
    
      ld: error: undefined symbol: __tsan_memcpy
      >>> referenced by cam_compat.c:150 (/usr/src/sys/cam/cam_compat.c:150)
      >>>               cam_compat.o:(cam_compat_handle_0x17)
      >>> referenced by cam_compat.c:151 (/usr/src/sys/cam/cam_compat.c:151)
      >>>               cam_compat.o:(cam_compat_handle_0x17)
      >>> referenced by cam_compat.c:152 (/usr/src/sys/cam/cam_compat.c:152)
      >>>               cam_compat.o:(cam_compat_handle_0x17)
      >>> referenced 1692 more times
    
    Similar to subr_msan.c, add aliases from the existing kcsan_* versions
    of these functions to __tsan_* names.
    
    Reviewed by:    markj
    MFC after:      3 days
    Differential Revision: https://reviews.freebsd.org/D39772
---
 sys/kern/subr_csan.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sys/kern/subr_csan.c b/sys/kern/subr_csan.c
index 8723777ce84b..f79c638b181c 100644
--- a/sys/kern/subr_csan.c
+++ b/sys/kern/subr_csan.c
@@ -301,6 +301,10 @@ kcsan_memmove(void *dst, const void *src, size_t len)
 	return __builtin_memmove(dst, src, len);
 }
 
+__strong_reference(kcsan_memcpy, __tsan_memcpy);
+__strong_reference(kcsan_memset, __tsan_memset);
+__strong_reference(kcsan_memmove, __tsan_memmove);
+
 char *
 kcsan_strcpy(char *dst, const char *src)
 {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202304231900.33NJ0gvq037610>