From patchwork Fri Mar 3 14:14:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 63941 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp432012wrd; Fri, 3 Mar 2023 06:16:05 -0800 (PST) X-Google-Smtp-Source: AK7set+QZhLBziPxFuZWcA9qCMT0o2mxGPE1pJXOOfLSsZ4EbsnlmErZzPLMy3+cHXbCtl/am6L0 X-Received: by 2002:a05:6a20:8403:b0:cc:76ec:70dc with SMTP id c3-20020a056a20840300b000cc76ec70dcmr3127757pzd.26.1677852965313; Fri, 03 Mar 2023 06:16:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677852965; cv=none; d=google.com; s=arc-20160816; b=flAsPDp7vniXllNn0yaQwuzhzRDa1ZhKK6VTrPHYGmOTiTzAK1H5+oM2nNQHhztWg3 c3wHP9uLz1Tq2xyFZHgZ3BRKuFiiTl2l39+maL8oR7duixLjzsV6sM/U9m3KhvMMBqm5 UzchS02wQaxyAr4/DfDlemhfPqsfGEuDX3RiQDgcgNHsO2S7xNFzJAG2Yo/2Ut8RybHZ 6We6PUdXynQojEIYVnq/0xIsRUadWxO73fooA2nYQY753O6OUyNwtAaOj16i+MJrRMCS VDEH55Z3LUO0pG4jQGTt+JeIRHcQ3xwpVUrn0XoNtCy/BYD4EEoQKtWbSzvY4ohuBap1 axJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=2N/CPy1IFmLQesHjkxJB5VDmlDO65TUQOL9xC78XNWQ=; b=n2d+/luSOLU7BRsCHcCNwNIEZh9k/cvGRpQctyP/uQl6PsWQzaT/KVSi2/Rn6FFWyW DHbRNYLGarf211T8DhrpFGLm7Yx9ILngKuzrcw0MTeisyopOCx9f4e3aDvETVZ2XUVDF ognzZ4gvmaAWCULz1prR/bFTWxUHD8jPCwrkXk3+iJjFwxnCO8sVSnxQw6KKZLvZynBw moC2TXtkUsvm4GMXipTzKiVqN916OBLqUEN57/q+ygV0lANEQu/hh6M+KaU6BoPEoaAx 0eE80ztxI4dsNvj5YyySOzxBuDH4OiZlBF+NHI6Y15qwLn5G57hmUjhzzzz3xRmTCc/e 9uSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=hMY2yJzs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k124-20020a632482000000b004fb165e159bsi2339171pgk.794.2023.03.03.06.15.51; Fri, 03 Mar 2023 06:16:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=hMY2yJzs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230510AbjCCOOn (ORCPT + 99 others); Fri, 3 Mar 2023 09:14:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230227AbjCCOOm (ORCPT ); Fri, 3 Mar 2023 09:14:42 -0500 Received: from mail-ed1-x54a.google.com (mail-ed1-x54a.google.com [IPv6:2a00:1450:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68B0913DEB for ; Fri, 3 Mar 2023 06:14:41 -0800 (PST) Received: by mail-ed1-x54a.google.com with SMTP id q13-20020a5085cd000000b004af50de0bcfso4216239edh.15 for ; Fri, 03 Mar 2023 06:14:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1677852880; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=2N/CPy1IFmLQesHjkxJB5VDmlDO65TUQOL9xC78XNWQ=; b=hMY2yJzsPf2YWJ9SnaLFMvgZa7mnCcGkPNLMoITa/8FWMXegqQl7kIJo/qWbFtv42K JUF3gcDP0cfK67S+1mdFC2TbAWAnhoc3q+tRpdXFcLyhBGTf0Opvr/qYA8Z6Oj+oe1PO azhktU12eLJhoB1eKldndx4jeQwB0Xkm5Yro83Pn9TkvQpP34l1jQU1wvOMFDuojTwoy nr3zYZv12m4lPIMp4NLUZBH3EtP7QEL/MlNPFBicPOgSwAROS0En6PD9ETZi/dZ8EYZt S93zuhDgiY/Zn126O3o8Vab4eMVHJMeE2Mpw/mURlt/0t2gHwSJCXA5K1fqYu1PAdxYy lHZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677852880; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=2N/CPy1IFmLQesHjkxJB5VDmlDO65TUQOL9xC78XNWQ=; b=Hva06/fizgI2iSmW2KN/XPfcg72zGgBLrruXTjIYh6H/Oc+RPnQmGm+lfN+4OeouDJ zSWlmb9Dscktf6lMiBd9kDSp3hKhk88wg7Ulr+A0VVpJ4k77b7TCbAIWH0Tjx5plLAz8 C/lEnykxUIlSL5kSEZIdtjDVDLGJFZ8E8w7UKG8SemgwGxfOvV6tsbiT0FcN6EXfzhMC PA/mCLwIbppreM+bdRZecwmfmaerRfyOoPuiHVOI3sgzEoJDPWyDdRBToJq8eDy7ZyFb hiZtEcAutxVWD9mEtaoaizgU+kQl7/BxlXEQ3rCTF2k+qnO4QmKA3Au05fTQCmI/SvYe gCbg== X-Gm-Message-State: AO0yUKWBAyyKgkNfYo9TWICWHOYWjYLoP1444YMvzWOe7Y3EoMLGdFUi M37klHPImJI4mb897nbmCeFHD0QMjUk= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:f11e:2fac:5069:a04d]) (user=glider job=sendgmr) by 2002:a50:ab1e:0:b0:4ab:4933:225b with SMTP id s30-20020a50ab1e000000b004ab4933225bmr1157914edc.6.1677852879922; Fri, 03 Mar 2023 06:14:39 -0800 (PST) Date: Fri, 3 Mar 2023 15:14:30 +0100 Mime-Version: 1.0 X-Mailer: git-send-email 2.40.0.rc0.216.gc4246ad0f0-goog Message-ID: <20230303141433.3422671-1-glider@google.com> Subject: [PATCH 1/4] x86: kmsan: Don't rename memintrinsics in uninstrumented files From: Alexander Potapenko To: glider@google.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, dave.hansen@linux.intel.com, hpa@zytor.com, akpm@linux-foundation.org, elver@google.com, dvyukov@google.com, nathan@kernel.org, ndesaulniers@google.com, kasan-dev@googlegroups.com, Kees Cook X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759356350916549299?= X-GMAIL-MSGID: =?utf-8?q?1759356350916549299?= clang -fsanitize=kernel-memory already replaces calls to memset/memcpy/memmove and their __builtin_ versions with __msan_memset/__msan_memcpy/__msan_memmove in instrumented files, so there is no need to override them. In non-instrumented versions we are now required to leave memset() and friends intact, so we cannot replace them with __msan_XXX() functions. Cc: Kees Cook Suggested-by: Marco Elver Signed-off-by: Alexander Potapenko Reviewed-by: Marco Elver --- v2: - updated patch description --- arch/x86/include/asm/string_64.h | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/arch/x86/include/asm/string_64.h b/arch/x86/include/asm/string_64.h index 888731ccf1f67..9be401d971a99 100644 --- a/arch/x86/include/asm/string_64.h +++ b/arch/x86/include/asm/string_64.h @@ -15,22 +15,11 @@ #endif #define __HAVE_ARCH_MEMCPY 1 -#if defined(__SANITIZE_MEMORY__) && defined(__NO_FORTIFY) -#undef memcpy -#define memcpy __msan_memcpy -#else extern void *memcpy(void *to, const void *from, size_t len); -#endif extern void *__memcpy(void *to, const void *from, size_t len); #define __HAVE_ARCH_MEMSET -#if defined(__SANITIZE_MEMORY__) && defined(__NO_FORTIFY) -extern void *__msan_memset(void *s, int c, size_t n); -#undef memset -#define memset __msan_memset -#else void *memset(void *s, int c, size_t n); -#endif void *__memset(void *s, int c, size_t n); #define __HAVE_ARCH_MEMSET16 @@ -70,13 +59,7 @@ static inline void *memset64(uint64_t *s, uint64_t v, size_t n) } #define __HAVE_ARCH_MEMMOVE -#if defined(__SANITIZE_MEMORY__) && defined(__NO_FORTIFY) -#undef memmove -void *__msan_memmove(void *dest, const void *src, size_t len); -#define memmove __msan_memmove -#else void *memmove(void *dest, const void *src, size_t count); -#endif void *__memmove(void *dest, const void *src, size_t count); int memcmp(const void *cs, const void *ct, size_t count);