From nobody Mon Nov 25 21:13:00 2024 X-Original-To: dev-commits-src-main@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 4Xxz245kctz5fCch; Mon, 25 Nov 2024 21:13:00 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Xxz243SFrz3yp6; Mon, 25 Nov 2024 21:13:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732569180; 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=p8UAaZo/CW+Wd0p/brmuq6T+mO+ruXNoNPurmq5hLc8=; b=J91gg7X0w/DNXKkms3V6vwacVX7It02ZbAMpqIE+qSX21LPWW6b17Gxqa2p5Ztt8EER6dk VyKG6UqDVXOsZpVylZnM+gjLPlMop9wg9jmvW5cGg4r3qq+yKxIvs5TGZ/Sh/MsgfKbxny +DUniDSbIGVHGh+ODXnd8Usi2+LozI02C04UCSt0xhNX2435PW6DPNJN8FL+Gbv9KWryms lPn8MjwINF+V2ku5l1lcdnxwlP0i5rJ1jFx751XZjDcNkK24FDYuSJVBnRgYpoZ3nximhb 2MfSCwu0mPAD8tGY8pwD+JMZ6D7j1qxh5Nthz0DpMP3GZE5qEKtfrn1L22COHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732569180; 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=p8UAaZo/CW+Wd0p/brmuq6T+mO+ruXNoNPurmq5hLc8=; b=uGRHcWpHM1MqZr0WCn47H3jDyA7ewXWbljDCqk8rTIadVQmtRkas8MT9wNcw0fCROiWyqE 9N3OU8U4Id56PJBKn2AqHaGw5k8hpfWUcsfXcVnq89LGPKfDwsSk54ZGsVqZxzI7ke1KBR Q+i5C70AIwy0cqURWyYmTrROG2fzMcrQZk96EymBcc4MMTPT0Vy6yR8JYWScv47taoF8DZ WyFNelCf8W7FvxLQLCY4bMvMvni1uGLxvzlUCqIpsqonwOL1R/K5yMMmPIBk11zoHPSJSM dlvRXljpBIgdmwZ+rTIw542AKGMiKcSRHw/Tgsb8oAAnEaOAUEG6xdDFsEg9hw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1732569180; a=rsa-sha256; cv=none; b=KJKh4rF/VIau7xjaWUuyQBWsUhP30jfdzOoMHoJ3yw2+GIETpPEb6c5hJjycoQulzNKyZZ gZf9SOHRYnr4OmRPuI17tDPfqB0EAjZ9mjt12tY9Mu03ep7vfPdCeA0GqcLPF2DlDKw3xI AHxLejnA9Xneg3o8/R8Iv1dnaEiB4VtjZioBbbj5ykP/kz2n14fOBrp16gcxo+xXUD4SHT aHyWwlI9lahWF7DyVoEhKnjE2AYbz4z2w3P/KkWmrd3H+IPfBnMXcYFfgaC7RSMz59V1JQ ih0TTGh+TeTPSfSOsy1a32FEQ3bY5wC89OD3C3CK8yTUJsy7UxboQrgATRjbGQ== 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 4Xxz2433dxzwpr; Mon, 25 Nov 2024 21:13:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4APLD022028014; Mon, 25 Nov 2024 21:13:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4APLD0Wa028011; Mon, 25 Nov 2024 21:13:00 GMT (envelope-from git) Date: Mon, 25 Nov 2024 21:13:00 GMT Message-Id: <202411252113.4APLD0Wa028011@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 37cef00192ef - main - livedump: Silence KASAN and KMSAN when livedumping List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 37cef00192ef1347d27ac64be419267a4ba604ac Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=37cef00192ef1347d27ac64be419267a4ba604ac commit 37cef00192ef1347d27ac64be419267a4ba604ac Author: Mark Johnston AuthorDate: 2024-11-25 21:11:37 +0000 Commit: Mark Johnston CommitDate: 2024-11-25 21:12:51 +0000 livedump: Silence KASAN and KMSAN when livedumping The livedumper triggers reports from both of these sanitizers since it necessarily accesses uninitialized or freed memory. Add a flag to silence reports from both sanitizers. Reviewed by: mhorne, khng MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D47714 --- sys/kern/kern_vnodedumper.c | 2 ++ sys/kern/subr_asan.c | 3 +++ sys/kern/subr_msan.c | 6 ++++++ sys/sys/proc.h | 1 + 4 files changed, 12 insertions(+) diff --git a/sys/kern/kern_vnodedumper.c b/sys/kern/kern_vnodedumper.c index 5a2c255390cc..c89e209cc1a5 100644 --- a/sys/kern/kern_vnodedumper.c +++ b/sys/kern/kern_vnodedumper.c @@ -133,8 +133,10 @@ livedump_start_vnode(struct vnode *vp, int flags, uint8_t compression) if (error != 0) goto out; + curthread->td_pflags2 |= TDP2_SAN_QUIET; dump_savectx(); error = minidumpsys(livedi, true); + curthread->td_pflags2 &= ~TDP2_SAN_QUIET; EVENTHANDLER_INVOKE(livedumper_finish); out: diff --git a/sys/kern/subr_asan.c b/sys/kern/subr_asan.c index 61466ffbf2ab..9f8a7bfccd40 100644 --- a/sys/kern/subr_asan.c +++ b/sys/kern/subr_asan.c @@ -405,6 +405,9 @@ kasan_shadow_check(unsigned long addr, size_t size, bool write, if (__predict_false(!kasan_enabled)) return; + if (__predict_false(curthread != NULL && + (curthread->td_pflags2 & TDP2_SAN_QUIET) != 0)) + return; if (__predict_false(size == 0)) return; if (__predict_false(kasan_md_unsupported(addr))) diff --git a/sys/kern/subr_msan.c b/sys/kern/subr_msan.c index 52ec5ce13bd1..1c18a4a4f8e5 100644 --- a/sys/kern/subr_msan.c +++ b/sys/kern/subr_msan.c @@ -179,6 +179,9 @@ kmsan_report_hook(const void *addr, msan_orig_t *orig, size_t size, size_t off, if (__predict_false(KERNEL_PANICKED() || kdb_active || kmsan_reporting)) return; + if (__predict_false(curthread != NULL && + (curthread->td_pflags2 & TDP2_SAN_QUIET) != 0)) + return; kmsan_reporting = true; __compiler_membar(); @@ -232,6 +235,9 @@ kmsan_report_inline(msan_orig_t orig, unsigned long pc) if (__predict_false(KERNEL_PANICKED() || kdb_active || kmsan_reporting)) return; + if (__predict_false(curthread != NULL && + (curthread->td_pflags2 & TDP2_SAN_QUIET) != 0)) + return; kmsan_reporting = true; __compiler_membar(); diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 69b6c7a61da0..c5ef4f849eab 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -567,6 +567,7 @@ enum { #define TDP2_SBPAGES 0x00000001 /* Owns sbusy on some pages */ #define TDP2_COMPAT32RB 0x00000002 /* compat32 ABI for robust lists */ #define TDP2_ACCT 0x00000004 /* Doing accounting */ +#define TDP2_SAN_QUIET 0x00000008 /* Disable warnings from K(A|M)SAN */ /* * Reasons that the current thread can not be run yet.