Message ID | 20220905122452.2258262-39-glider@google.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A059C6FA83 for <linux-mm@archiver.kernel.org>; Mon, 5 Sep 2022 12:26:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF8C68D008D; Mon, 5 Sep 2022 08:26:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DA9B48D0076; Mon, 5 Sep 2022 08:26:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C495B8D008D; Mon, 5 Sep 2022 08:26:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id B1C7E8D0076 for <linux-mm@kvack.org>; Mon, 5 Sep 2022 08:26:43 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9A6CF14035D for <linux-mm@kvack.org>; Mon, 5 Sep 2022 12:26:43 +0000 (UTC) X-FDA: 79877955486.26.39FA3C9 Received: from mail-ed1-f74.google.com (mail-ed1-f74.google.com [209.85.208.74]) by imf24.hostedemail.com (Postfix) with ESMTP id 46FF518008C for <linux-mm@kvack.org>; Mon, 5 Sep 2022 12:26:43 +0000 (UTC) Received: by mail-ed1-f74.google.com with SMTP id l19-20020a056402255300b0043df64f9a0fso5758968edb.16 for <linux-mm@kvack.org>; Mon, 05 Sep 2022 05:26:43 -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=B20xXcKs3s8hrSiIPawsoAQNJNH2pIVNO9ri0lLBzXqBzeW3T8m6K9mMcQYVvqd4mF aM0s1ZcgrBzGUUNociKf7h5AVwpd5uOCgs/jd02L+fLKsrmP91eIf/Mf07OZI1S6/ZmX ob2gG+WMUfpulLQiwbqdxUfda3FIS08njwQDtbVDfIdTEnomhfwr8/j3Fa9x6fUbDN80 muT7FTQjPUUJv/iiMWcHWFojduldRGbuIjuQENOlXO4vm1LlZycXXzSFtpc+N1VSRCQK wLHjDKs9ei5uA2IwwFuLjq08QnTmwlPQm6BtPT69GhuC52o7N+aFAebEWRMHKh4ADCis EAUg== X-Gm-Message-State: ACgBeo2JPYBZ+Ro6z3gf2e9Z80ox1pR5JVylmFaQEbJg5Awl+z9DuhNb B3ORkePTltI7lykFdTr+QL+I0Kt9sjs= X-Google-Smtp-Source: AA6agR7MDr6BOPDfZGI9VUpdu+EDSsR8WTCobkcNLw4fbja27oiV7sHYlc5Qaiw4Oc2k8IXLG99/Xrjflgw= 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 <glider@google.com> To: glider@google.com Cc: Alexander Viro <viro@zeniv.linux.org.uk>, Alexei Starovoitov <ast@kernel.org>, Andrew Morton <akpm@linux-foundation.org>, Andrey Konovalov <andreyknvl@google.com>, Andy Lutomirski <luto@kernel.org>, Arnd Bergmann <arnd@arndb.de>, Borislav Petkov <bp@alien8.de>, Christoph Hellwig <hch@lst.de>, Christoph Lameter <cl@linux.com>, David Rientjes <rientjes@google.com>, Dmitry Vyukov <dvyukov@google.com>, Eric Dumazet <edumazet@google.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Herbert Xu <herbert@gondor.apana.org.au>, Ilya Leoshkevich <iii@linux.ibm.com>, Ingo Molnar <mingo@redhat.com>, Jens Axboe <axboe@kernel.dk>, Joonsoo Kim <iamjoonsoo.kim@lge.com>, Kees Cook <keescook@chromium.org>, Marco Elver <elver@google.com>, Mark Rutland <mark.rutland@arm.com>, Matthew Wilcox <willy@infradead.org>, "Michael S. Tsirkin" <mst@redhat.com>, Pekka Enberg <penberg@kernel.org>, Peter Zijlstra <peterz@infradead.org>, Petr Mladek <pmladek@suse.com>, Steven Rostedt <rostedt@goodmis.org>, Thomas Gleixner <tglx@linutronix.de>, Vasily Gorbik <gor@linux.ibm.com>, Vegard Nossum <vegard.nossum@oracle.com>, Vlastimil Babka <vbabka@suse.cz>, 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662380803; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=UAXLi6hWes4K0I7wTwgH8ix0vMuStYu2bu/++oTzO6o=; b=eAmx6nUOaV3HXrj6xHvnt9mAQvVJzHU21BpKsqE1jSfGgFpiP/yM4pytfa/su9u4YhY/Xi LOOlJPBGCY5q1GtysbD8I+e3Pm1UBFSuvv9a/ygFzRblDxpcXqwqfF6v8rItzQayWEmq1B QWACXMfgozJLE0b1y9gXZBg1XOmBzIo= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=IiXcuANz; spf=pass (imf24.hostedemail.com: domain of 3AusVYwYKCE8x2zuv8x55x2v.t532z4BE-331Crt1.58x@flex--glider.bounces.google.com designates 209.85.208.74 as permitted sender) smtp.mailfrom=3AusVYwYKCE8x2zuv8x55x2v.t532z4BE-331Crt1.58x@flex--glider.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662380803; a=rsa-sha256; cv=none; b=P1YYrOWVO+MuDpXJ27ymqYL+KOKakkJNL8BUE55vZ9VIBweRavqWhDrdiJ6UiVyQXsZfdQ 0Wekczx5HtMQfFmbxTmq9fthf+2wLrvbEKuCVTeWBoUJn9oKz+kp1WeY+vGPHJxue0SXad /sF8y8Ehwo61RiMNNHGoNu8VWwO1pbQ= X-Rspam-User: X-Stat-Signature: 54si6hcofjxex7sywfwh1rijf7bkrgnn X-Rspamd-Queue-Id: 46FF518008C Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=IiXcuANz; spf=pass (imf24.hostedemail.com: domain of 3AusVYwYKCE8x2zuv8x55x2v.t532z4BE-331Crt1.58x@flex--glider.bounces.google.com designates 209.85.208.74 as permitted sender) smtp.mailfrom=3AusVYwYKCE8x2zuv8x55x2v.t532z4BE-331Crt1.58x@flex--glider.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam04 X-HE-Tag: 1662380803-338689 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> |
Series |
Add KernelMemorySanitizer infrastructure
|
expand
|
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 <asm/checksum_32.h> +#ifdef CONFIG_GENERIC_CSUM +# include <asm-generic/checksum.h> #else -# include <asm/checksum_64.h> +# 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 <asm/checksum_32.h> +# else +# include <asm/checksum_64.h> +# 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
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 <glider@google.com> --- 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(-)