Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp3056787rwb; Mon, 5 Sep 2022 05:59:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR5FrTz8y/5Ir37owqy99V20lAZnIBCS8e0Vl6HWKraESy9CwaePy+08tTlIfEQtPYfRjfNw X-Received: by 2002:a17:90b:1bc6:b0:1f5:313a:de4b with SMTP id oa6-20020a17090b1bc600b001f5313ade4bmr19706086pjb.4.1662382765724; Mon, 05 Sep 2022 05:59:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662382765; cv=none; d=google.com; s=arc-20160816; b=HOoJq/VQ4C/XXQ3JkdTgFUlXlm2UKlsH2LrWJB2NZR533LtSB6CrXMO6wri7oQVNOH prfyn/to4HfyVLxBLGUWUcJ0sxWc0ViFhj3yuvBKiJRVy/nBNgIQGXjIgbkkztcYtPci RvQ1GlpcvqJeqp3R+RXo5DJm8j+rmBgirlBcb9+XYGWk15CyA1FJf0QDuHEuB2Yl3wAQ UEOEzYNt8q7LRbgwYinHyIfVyC47cOukAyK4hd63gMig9D5Ef73H2Z4Gr3aQZPX2jHJ8 MOXoaY/kNM/NwCY5J05aZFKPAJUeyNiDUguDyJ4Fpmuqtccr4ObeINmtGHeoO1LwUmt4 ayRA== 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=ZxeyxP2Rt55kSZT6IPmU/wyIAvcg4hB8ao8YTD9U+aB+sAB/6K7++XhTJoE+rUo3Y9 kPd/KAdNga98a39bvMtII/3jbVMfZB8AN5iL+5eY0M0wiZwsWC84Dx3aKX78244qkgmF K0xDzsuPUBfGStvDJPFZE8rIS5c7n0SYovS/TOaufTp3499qqF88EPV9HTRWVx6wvSZm Ucq/WPyEwhQiViCYeUv7cNAja5DWWGO4/bSla9A4RzdCz1qoRRqki74wFrbrHk4ukqUw kEDTjj1rJSQtY6kas7+km8ErA37d75ElPHlzHXK+tjeFo626lAtRJ370MWDKc9Q8mt1S RziA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=IiXcuANz; 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 m21-20020a634c55000000b004306b9b9730si8473794pgl.132.2022.09.05.05.59.13; Mon, 05 Sep 2022 05:59:25 -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=IiXcuANz; 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 S237050AbiIEMcm (ORCPT + 99 others); Mon, 5 Sep 2022 08:32:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237973AbiIEMaq (ORCPT ); Mon, 5 Sep 2022 08:30:46 -0400 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 AB10A60690 for ; Mon, 5 Sep 2022 05:26:44 -0700 (PDT) Received: by mail-ed1-x54a.google.com with SMTP id w19-20020a05640234d300b004482dd03feeso5727847edc.0 for ; Mon, 05 Sep 2022 05:26:44 -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=IiXcuANzOXVeghkyw45jIMRJOD8tJCWr7Q1BUgEz0fm35aYdWZX4D683Pva/+zNLad choRXGR+vUulOeBWEDGvOCuy/XY+TgrqANSjoAj0HTZHuhSXRl0uaBoC9IohaljDqOSw lHnzDdCFB3MwKou7/Xmijnr1q4RL7SKQSLJrgFR5I0C2bUbU1QmYTqovQCM2Xy1SHffm d3owLA3ha4/6k+UDm+7p/tlCYtuTh4p4aZioY467gpQIBRQTy+ELgVXgJZk8GQRjZN4q UQUIUId5D4WLT9t/nPPBAtfQjbnc0NkSg0OyN+VUeEPZgk5kBTa88vDc+Z5HF7RV6MNo Hz1w== 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=mz4dE6rnUH4odbbsWzzplD4nQsysbUSTUiT8crceP2QbmHSh6TUhTtU8dK6e0bToPv BttbiRpq0a6vrDX6/2g8SgWnDFfPg7U1QOYNbDwbe0NWQBnFE/DoX7RWSSTg+1P5bcVi 5yWGHJ0ipsSzeZswIU/XtsRvbv3Z1W6LDwHe2hwYIu+eeG+/IeYmlACC4SyoglPu8Ncw cEbDsSpnX1dCpXVycTTbT/aD5zUPgtMv1WldtJeE0kGUjQWkRktXhUcS6ia02Do9oJrf z1DwKSMtek2sEh/ipGQ25b38aXtwtLU1V4Zi6C2x1cJWittSZuVNKWDqcqJUqVyPWu9g 6nug== X-Gm-Message-State: ACgBeo0AL3iRAuVuYUc45AsrG1XhKQYNBBN7EqaEj6dkQ0PplYifyEqY +ccmvRADPJhdSa3AEFIeMpbLAHfa+xY= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:b808:8d07:ab4a:554c]) (user=glider job=sendgmr) by 2002:a17:907:7d8f:b0:732:9d6c:4373 with SMTP id oz15-20020a1709077d8f00b007329d6c4373mr33515704ejc.493.1662380802045; Mon, 05 Sep 2022 05:26:42 -0700 (PDT) Date: Mon, 5 Sep 2022 14:24:46 +0200 In-Reply-To: <20220905122452.2258262-1-glider@google.com> Mime-Version: 1.0 References: <20220905122452.2258262-1-glider@google.com> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog Message-ID: <20220905122452.2258262-39-glider@google.com> Subject: [PATCH v6 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" 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,T_SCC_BODY_TEXT_LINE,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