From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5401CECAAD7 for ; Fri, 26 Aug 2022 15:16:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244642AbiHZPQH (ORCPT ); Fri, 26 Aug 2022 11:16:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344373AbiHZPOk (ORCPT ); Fri, 26 Aug 2022 11:14:40 -0400 Received: from mail-ej1-x649.google.com (mail-ej1-x649.google.com [IPv6:2a00:1450:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D06177E9C for ; Fri, 26 Aug 2022 08:10:03 -0700 (PDT) Received: by mail-ej1-x649.google.com with SMTP id hs4-20020a1709073e8400b0073d66965277so711902ejc.6 for ; Fri, 26 Aug 2022 08:10:02 -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; bh=G7zTeV7HivGGK7/AmFGwNvvgE+xYoTaOW1pCL0nph+s=; b=rllUU8td54J92uwD4gqMdf7quRrn9vs+RF/VGfmhTNifoonDDOGDzA+ehk2F0Nktis bzsb1L86DwkC+0Lwn7biXr7xSRRAyztcTTabYoOev0SalCjTFvsRPApNrtWrG92arrNL vYy30mjcDtboOMLaYF/EGB9Bb67OhSnqrd9929GMzB46msZdCnUGmupRwBiLOAMpOTu/ xgXxZRY8JK8LqcDPH4Z1qbgGAF+6QrIMppgLaa1fjdmq/jeISdUH5rHhnHGN0itBSODe GmUzrI95aXvhJ1Ss7JdEnAwqbHxBSkafgMVWr/h9flFgsjbzEK99uA8DU4lsh1XM5zFP k9rw== 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; bh=G7zTeV7HivGGK7/AmFGwNvvgE+xYoTaOW1pCL0nph+s=; b=ky2DMsusr2X1h9d3AJRDdMK3zUDUFLKk52tgWqhR7Exm5i225ZmfsghyoEQE5vw1GN D3C+yTpx6dSE064bBPxqjxAF6vjIhGXsjwUH34KwBJRijPshKeLV/Lm5HrpYsxa8p47M 0dczajXaYzOnH5OuCllCGQaJXdIAVNMhtsqVGrFZ2GYgSFDY/6XrGMo3Ljub+gbWXbwF LKKiA1MGFXxCuP+eF+c2+NenSbUORXDNyJF1L8S6OZg1FI9HBG4MVP4ApkODJ37WpNMw 9ITTgZ3x6qCvBATHnWhYL4lx/rhMayOIzGtvcJ45JQWviGJWy8equQJU19ahBtTx9fyY R9Kw== X-Gm-Message-State: ACgBeo0+1CNvtKpyMCGvpd2k5NySxsqH0LRMBEss/vV0KJxc7e97waab J6tNm6D24yk+Z7C5gUurYZHTspS08tw= X-Google-Smtp-Source: AA6agR6mygGnpoLM0Fz1GI/HNspwZBf2HxeWieGPgMrRMoJDYKMR11CPv0kXU0SX1XneClLqmTxEKKFSAKQ= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:5207:ac36:fdd3:502d]) (user=glider job=sendgmr) by 2002:a17:907:b17:b0:72a:edb8:7529 with SMTP id h23-20020a1709070b1700b0072aedb87529mr5717591ejl.749.1661526599889; Fri, 26 Aug 2022 08:09:59 -0700 (PDT) Date: Fri, 26 Aug 2022 17:08:01 +0200 In-Reply-To: <20220826150807.723137-1-glider@google.com> Mime-Version: 1.0 References: <20220826150807.723137-1-glider@google.com> X-Mailer: git-send-email 2.37.2.672.g94769d06f0-goog Message-ID: <20220826150807.723137-39-glider@google.com> Subject: [PATCH v5 38/44] 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 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 , 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" Precedence: bulk List-ID: X-Mailing-List: linux-arch@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.672.g94769d06f0-goog