From nobody Mon Nov 14 19:42:11 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NB07m0Bl4z4d9Wf; Mon, 14 Nov 2022 19:42:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NB07l3ZW8z3Jk7; Mon, 14 Nov 2022 19:42:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668454931; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qqSvLlj1AblVE6RedlJcBTk1UGjo0Ousowgq4Sy5kXE=; b=Yl519bXvdQPFkgWVhdaf/p/6/wsOLMAYWwfCftd975lT0pejsuKtj+sk1JumlSiv6+TFX7 zNqzcNfI8REM7YYjBHCxcIsydu8B5uQrLU/Rat59yHyLdyNQ7fYt8QfnKPIN03GBL6jPDe SH9IDYi4QjGho6g2GzwnB4RX9U7GJnjDvKK0JGrzSPWXXBBcV1bqdqOXdWXw+hW+mszwPr 0kobf1aq0Wl+Ay45lRGirSsV1GorQnEv3gC3nmNDHH4k6Kqv6q0eBsj8VwGxFakTxkpW3l HfvefC+XcAAGPWr+8b5E7p5q3C4TXuxAUpBdgSb+We37czABdOVpCbthiLbKEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668454931; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qqSvLlj1AblVE6RedlJcBTk1UGjo0Ousowgq4Sy5kXE=; b=tpRCd/X2n2Nvs2s5gr03RV28c2akt3YYd52Op4sWm/+fx+OS31d+hceDrMTsVMdSFap5Ok OPnZchyPxjj/j9LCpgjme3l6jDkEcSdNwARisrVXC4VfEkhJJCCywJtKA41R7KbuJRugev guvwEZ+3yENR0qlFGgqH9d7dduWMdBAiGT6YiFM6oLadPwvXc7Dztmb1cytwXmZ0BSpa9O 2y50ni09dHKG6KhvYH+GsRMoLVGsDcZufLK7bFXLU2Dpp7xURPILPUrm0DLyaaQ+6K2dXE 1xF/yIK/C9Q0e4b3JSAAVUwY3LIsx4l/Y5c2FdKAWruS3FHkwyglFjAGv4MwQA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1668454931; a=rsa-sha256; cv=none; b=UWL0rQsWPyKmJWYB+FjeRhNwi8nyPrn5uHWwmVRF5vJlHVBkQgqKRVN7OFdx/IwlXIeHIj IdPUpShYtgcmHKMs01WcJRnXm+6a8EZjh3KTxMonndI4EEQnXsXueCHKbKNTKZgMcUi6w0 7pcmXCpRTgVPDSAjnOfQRDrzzbLyaQpX3WHUP+QPkxET0RfcNWGcaeDLx64aGsVRbcauF7 /M/lsfzUaz+VG9+Er4EEGbINFOE1rXblYRh+jBAv8zTU2/lje4j07PFMEPd9GC34mGZLHi qr9ct1EefiPqeEfYRzRaWO+g+QQ/Zf1YXz1frXeNQtr7VPD5QhaGP+GUzpGTjQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NB07l2glHztvt; Mon, 14 Nov 2022 19:42:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2AEJgBdw050775; Mon, 14 Nov 2022 19:42:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AEJgBvP050774; Mon, 14 Nov 2022 19:42:11 GMT (envelope-from git) Date: Mon, 14 Nov 2022 19:42:11 GMT Message-Id: <202211141942.2AEJgBvP050774@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 54fe9183c8f9 - stable/13 - atomic: Intercept atomic_(load|store)_bool for kernel sanitizers List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 54fe9183c8f995b3b6811d1302a166405dce9af2 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=54fe9183c8f995b3b6811d1302a166405dce9af2 commit 54fe9183c8f995b3b6811d1302a166405dce9af2 Author: Mark Johnston AuthorDate: 2022-10-29 15:02:02 +0000 Commit: Mark Johnston CommitDate: 2022-11-14 19:24:47 +0000 atomic: Intercept atomic_(load|store)_bool for kernel sanitizers Fixes: 2bed73739aac ("atomic: Add plain atomic_load/store_bool()") (cherry picked from commit 1f6b6cf1774c4f173df1cde3e5cff459f340c95f) --- sys/kern/subr_asan.c | 2 ++ sys/kern/subr_csan.c | 3 +++ sys/sys/atomic_san.h | 18 ++++++++++++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/sys/kern/subr_asan.c b/sys/kern/subr_asan.c index 30b05c54cd16..2f0334cf52be 100644 --- a/sys/kern/subr_asan.c +++ b/sys/kern/subr_asan.c @@ -754,6 +754,7 @@ ASAN_ATOMIC_FUNC_FCMPSET(int, u_int); ASAN_ATOMIC_FUNC_FCMPSET(long, u_long); ASAN_ATOMIC_FUNC_FCMPSET(ptr, uintptr_t); +_ASAN_ATOMIC_FUNC_LOAD(bool, bool); ASAN_ATOMIC_FUNC_LOAD(8, uint8_t); ASAN_ATOMIC_FUNC_LOAD(16, uint16_t); ASAN_ATOMIC_FUNC_LOAD(32, uint32_t); @@ -764,6 +765,7 @@ ASAN_ATOMIC_FUNC_LOAD(int, u_int); ASAN_ATOMIC_FUNC_LOAD(long, u_long); ASAN_ATOMIC_FUNC_LOAD(ptr, uintptr_t); +_ASAN_ATOMIC_FUNC_STORE(bool, bool); ASAN_ATOMIC_FUNC_STORE(8, uint8_t); ASAN_ATOMIC_FUNC_STORE(16, uint16_t); ASAN_ATOMIC_FUNC_STORE(32, uint32_t); diff --git a/sys/kern/subr_csan.c b/sys/kern/subr_csan.c index 7bed25076fa9..3a542207fbfb 100644 --- a/sys/kern/subr_csan.c +++ b/sys/kern/subr_csan.c @@ -520,6 +520,9 @@ kcsan_copyout(const void *kaddr, void *uaddr, size_t len) return (atomic_testandset_##name(ptr, val)); \ } +_CSAN_ATOMIC_FUNC_LOAD(bool, bool) +_CSAN_ATOMIC_FUNC_STORE(bool, bool) + CSAN_ATOMIC_FUNC_ADD(8, uint8_t) CSAN_ATOMIC_FUNC_CLEAR(8, uint8_t) CSAN_ATOMIC_FUNC_CMPSET(8, uint8_t) diff --git a/sys/sys/atomic_san.h b/sys/sys/atomic_san.h index b0790962d8bd..1f7d615ebd11 100644 --- a/sys/sys/atomic_san.h +++ b/sys/sys/atomic_san.h @@ -65,11 +65,15 @@ type sp##_atomic_readandclear_##name(volatile type *) #define ATOMIC_SAN_LOAD(sp, name, type) \ - type sp##_atomic_load_##name(volatile type *); \ + type sp##_atomic_load_##name(volatile type *) + +#define ATOMIC_SAN_LOAD_ACQ(sp, name, type) \ type sp##_atomic_load_acq_##name(volatile type *) #define ATOMIC_SAN_STORE(sp, name, type) \ - void sp##_atomic_store_##name(volatile type *, type); \ + void sp##_atomic_store_##name(volatile type *, type) + +#define ATOMIC_SAN_STORE_REL(sp, name, type) \ void sp##_atomic_store_rel_##name(volatile type *, type) #define ATOMIC_SAN_TEST(sp, op, name, type) \ @@ -86,6 +90,10 @@ #define ATOMIC_SAN_THREAD_FENCE(sp) \ _ATOMIC_SAN_THREAD_FENCE(sp) +#define ATOMIC_SAN_LOAD_STORE(sp, name, type) \ + ATOMIC_SAN_LOAD(sp, name, type); \ + ATOMIC_SAN_STORE(sp, name, type) + #define _ATOMIC_SAN_FUNCS(sp, name, type) \ ATOMIC_SAN_FUNC_1(sp, add, name, type); \ ATOMIC_SAN_FUNC_1(sp, clear, name, type); \ @@ -93,10 +101,12 @@ ATOMIC_SAN_FCMPSET(sp, name, type); \ ATOMIC_SAN_READ(sp, fetchadd, name, type); \ ATOMIC_SAN_LOAD(sp, name, type); \ + ATOMIC_SAN_LOAD_ACQ(sp, name, type); \ ATOMIC_SAN_READANDCLEAR(sp, name, type); \ ATOMIC_SAN_FUNC_1(sp, set, name, type); \ ATOMIC_SAN_FUNC_1(sp, subtract, name, type); \ ATOMIC_SAN_STORE(sp, name, type); \ + ATOMIC_SAN_STORE_REL(sp, name, type); \ ATOMIC_SAN_READ(sp, swap, name, type); \ ATOMIC_SAN_TEST(sp, testandclear, name, type); \ ATOMIC_SAN_TEST(sp, testandset, name, type) @@ -113,6 +123,7 @@ ATOMIC_SAN_FUNCS(8, uint8_t); ATOMIC_SAN_FUNCS(16, uint16_t); ATOMIC_SAN_FUNCS(32, uint32_t); ATOMIC_SAN_FUNCS(64, uint64_t); +ATOMIC_SAN_LOAD_STORE(SAN_INTERCEPTOR_PREFIX, bool, bool); ATOMIC_SAN_THREAD_FENCE(SAN_INTERCEPTOR_PREFIX); #ifndef SAN_RUNTIME @@ -125,6 +136,9 @@ ATOMIC_SAN_THREAD_FENCE(SAN_INTERCEPTOR_PREFIX); #define ATOMIC_SAN(func) \ __CONCAT(SAN_INTERCEPTOR_PREFIX, __CONCAT(_atomic_, func)) +#define atomic_load_bool ATOMIC_SAN(load_bool) +#define atomic_store_bool ATOMIC_SAN(store_bool) + #define atomic_add_char ATOMIC_SAN(add_char) #define atomic_add_acq_char ATOMIC_SAN(add_acq_char) #define atomic_add_rel_char ATOMIC_SAN(add_rel_char)