Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp972536rwn; Thu, 15 Sep 2022 08:42:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4rqtXd2iAzBKkTIkyYxV2lqheqS8ebFS0B2psNV1i+E6C9JbnpAtA3sb5m2Azr1CzbpnXm X-Received: by 2002:a05:6402:402a:b0:449:2ae0:aa9a with SMTP id d42-20020a056402402a00b004492ae0aa9amr407487eda.420.1663256565808; Thu, 15 Sep 2022 08:42:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663256565; cv=none; d=google.com; s=arc-20160816; b=Q/vrHqnofS+pbzDRDxsyjyNqWfN8j+pJeaJNVnPshSjOKIfdDZ3afKstwCV6Sj3eMN aU8y+PX41m5ZWxL2APVb96cI41RnVMxOq5W0Tg+tqVaH0Th3Rjngkfo82yf5MYSlVSNA lvtOerWlYOc2KYbNztV5LfPIRBlqYHfRQl0YEBbDGCghUgr0ok9Q02Z4n0hRGXbsUTpO xx93SyfJYC4p5fkXeQaQ0KFVTgQqiJK+rw8+fNB48ISyR1S7+5kYIz8TUWnB3aKJEJ8j LlfmfzUDkOjYL4mvkFSQ8kaVidmwV3FuAvU3JHOzwDwwsuudJsbRxWHlVIbcGRC4uKW2 WlpQ== 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:references :mime-version:in-reply-to:date:dkim-signature; bh=UAXLi6hWes4K0I7wTwgH8ix0vMuStYu2bu/++oTzO6o=; b=bgK8trMOsV4MM1T7rJZY1D9hVeL7IKVfHkh2kPLnG1ZwY3MnqzeLoQIIfQv0xD9mi+ HW3HKJjUUExkrMOfyG3rkYAfEdooo69WX1mOOv2H0LAIgp3ojeBIil5J9ypXVQK+63fW sw3mAenNG0CzCBwjqgBfdZ1WZwCJTTw2QzaDdo1B84U79/r1FJ/dQpqe5iV4OSSMUibP cFYl3XD5vsoIi1c0WHI58B2RNWb1v0MioUfTCql8MrpElywqSl+XvLJ/Dc19LJD9DIuA A3TtVc4E2LYijDstM6JfK98YycpzJ/C8dqwP1wi8X4BxNUMKDY+ue0CC2eULoNQrHGJk 8OYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ERCi1CpV; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x3-20020a05640226c300b0043999754363si19028065edd.516.2022.09.15.08.42.20; Thu, 15 Sep 2022 08:42:45 -0700 (PDT) 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=ERCi1CpV; 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 S230523AbiIOPLz (ORCPT + 99 others); Thu, 15 Sep 2022 11:11:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230527AbiIOPJw (ORCPT ); Thu, 15 Sep 2022 11:09:52 -0400 Received: from mail-ej1-x64a.google.com (mail-ej1-x64a.google.com [IPv6:2a00:1450:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBB2C9C2F9 for ; Thu, 15 Sep 2022 08:06:20 -0700 (PDT) Received: by mail-ej1-x64a.google.com with SMTP id qa33-20020a17090786a100b0077a69976d24so6992002ejc.7 for ; Thu, 15 Sep 2022 08:06:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date; bh=UAXLi6hWes4K0I7wTwgH8ix0vMuStYu2bu/++oTzO6o=; b=ERCi1CpV4jZif78HFY8gJQN4P8IDxcWvvUgCJpc8tDdg16sYqfI+n7+eI/UuSCUmAL SRsI5Hb91SXSeFx5sJE1WSEv/4pORbIjsWZTzgEFYcgB/oZjvlbdnJymDpzxMI9WqsSA fzkKSe+qfBYibckT/e2O3pBw/nejcxC4oW7V9C7vbDKbUxY/1oiLcrrUCzDCYPL0adsT b2RNlS/5f0ZdOsGOr5ezTbcfH4d1nDZoSyn+/iVHMh1x3nzhYUV/wDYZq+9D8wPhUAkh ifAj5YfBWK0ZWXgVZXSMG/CcCXlZscKX8+i4U7n68cPdraXGc+ejH1kH30GZoeyXCaAN BRHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date; bh=UAXLi6hWes4K0I7wTwgH8ix0vMuStYu2bu/++oTzO6o=; b=m0ueQQoYa/82IhIJ5UjRrTpgAoa7MQdmUDa1qGG+5Z2EO5sPNGYcH3YR3zELqiSUwH Pm8AdYdiqygPlKEXYQ69/4fmAclOR8mX8uoezpeJsaJiNi39FPH7sxuLR9LgGWaWGW+T d8ZptSL/rTa6cFGFubeNIU85apkwoCI0wwVvlJvZq/LSirRh8FbqCNUZ2dioPwN7rqWd /7kOPM90zlBlxXCOlsx24gch1tgCRbQbbbsOfbuGKKuCpTBDW/tlis2QDOZ1cdIlJ66C PZ5J96sT3CA7ay8oGSul4nvqkrELtA8wPb6q9ZVtO/2m1lbE0G0opRDdDm79rbrRTLY8 TFQA== X-Gm-Message-State: ACrzQf2P3ZnfqYc+BhptcRUCjpEE+v+DmO/w3cT1NB8cLV0GBdOJEn7/ thfEm8efgT+dw2PTiDI8Q6i8cyzWmhg= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:686d:27b5:495:85b7]) (user=glider job=sendgmr) by 2002:aa7:ca50:0:b0:44e:973b:461e with SMTP id j16-20020aa7ca50000000b0044e973b461emr269636edt.414.1663254379373; Thu, 15 Sep 2022 08:06:19 -0700 (PDT) Date: Thu, 15 Sep 2022 17:04:11 +0200 In-Reply-To: <20220915150417.722975-1-glider@google.com> Mime-Version: 1.0 References: <20220915150417.722975-1-glider@google.com> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog Message-ID: <20220915150417.722975-38-glider@google.com> Subject: [PATCH v7 37/43] x86: kasan: kmsan: support CONFIG_GENERIC_CSUM on x86, enable it for KASAN/KMSAN From: Alexander Potapenko To: glider@google.com Cc: Alexander Viro , Alexei Starovoitov , Andrew Morton , Andrey Konovalov , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Christoph Hellwig , Christoph Lameter , David Rientjes , Dmitry Vyukov , Eric Biggers , Eric Dumazet , Greg Kroah-Hartman , Herbert Xu , Ilya Leoshkevich , Ingo Molnar , Jens Axboe , Joonsoo Kim , Kees Cook , Marco Elver , Mark Rutland , Matthew Wilcox , "Michael S. Tsirkin" , Pekka Enberg , Peter Zijlstra , Petr Mladek , Stephen Rothwell , Steven Rostedt , Thomas Gleixner , Vasily Gorbik , Vegard Nossum , Vlastimil Babka , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" 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=unavailable 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 This is needed to allow memory tools like KASAN and KMSAN see the memory accesses from the checksum code. Without CONFIG_GENERIC_CSUM the tools can't see memory accesses originating from handwritten assembly code. For KASAN it's a question of detecting more bugs, for KMSAN using the C implementation also helps avoid false positives originating from seemingly uninitialized checksum values. Signed-off-by: Alexander Potapenko --- Link: https://linux-review.googlesource.com/id/I3e95247be55b1112af59dbba07e8cbf34e50a581 --- arch/x86/Kconfig | 4 ++++ arch/x86/include/asm/checksum.h | 16 ++++++++++------ arch/x86/lib/Makefile | 2 ++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index f9920f1341c8d..33f4d4baba079 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -324,6 +324,10 @@ config GENERIC_ISA_DMA def_bool y depends on ISA_DMA_API +config GENERIC_CSUM + bool + default y if KMSAN || KASAN + config GENERIC_BUG def_bool y depends on BUG diff --git a/arch/x86/include/asm/checksum.h b/arch/x86/include/asm/checksum.h index bca625a60186c..6df6ece8a28ec 100644 --- a/arch/x86/include/asm/checksum.h +++ b/arch/x86/include/asm/checksum.h @@ -1,9 +1,13 @@ /* SPDX-License-Identifier: GPL-2.0 */ -#define _HAVE_ARCH_COPY_AND_CSUM_FROM_USER 1 -#define HAVE_CSUM_COPY_USER -#define _HAVE_ARCH_CSUM_AND_COPY -#ifdef CONFIG_X86_32 -# include +#ifdef CONFIG_GENERIC_CSUM +# include #else -# include +# define _HAVE_ARCH_COPY_AND_CSUM_FROM_USER 1 +# define HAVE_CSUM_COPY_USER +# define _HAVE_ARCH_CSUM_AND_COPY +# ifdef CONFIG_X86_32 +# include +# else +# include +# endif #endif diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile index f76747862bd2e..7ba5f61d72735 100644 --- a/arch/x86/lib/Makefile +++ b/arch/x86/lib/Makefile @@ -65,7 +65,9 @@ ifneq ($(CONFIG_X86_CMPXCHG64),y) endif else obj-y += iomap_copy_64.o +ifneq ($(CONFIG_GENERIC_CSUM),y) lib-y += csum-partial_64.o csum-copy_64.o csum-wrappers_64.o +endif lib-y += clear_page_64.o copy_page_64.o lib-y += memmove_64.o memset_64.o lib-y += copy_user_64.o -- 2.37.2.789.g6183377224-goog