Message ID | 20220915150417.722975-38-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 B79E2ECAAA1 for <linux-mm@archiver.kernel.org>; Thu, 15 Sep 2022 15:06:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 58B728D0008; Thu, 15 Sep 2022 11:06:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4EC368D0001; Thu, 15 Sep 2022 11:06:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 38D678D0008; Thu, 15 Sep 2022 11:06:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 299CF8D0001 for <linux-mm@kvack.org>; Thu, 15 Sep 2022 11:06:21 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 0E0631C317B for <linux-mm@kvack.org>; Thu, 15 Sep 2022 15:06:21 +0000 (UTC) X-FDA: 79914645762.07.F8E3AA5 Received: from mail-ej1-f74.google.com (mail-ej1-f74.google.com [209.85.218.74]) by imf03.hostedemail.com (Postfix) with ESMTP id B487C2009F for <linux-mm@kvack.org>; Thu, 15 Sep 2022 15:06:20 +0000 (UTC) Received: by mail-ej1-f74.google.com with SMTP id gv43-20020a1709072beb00b0077c3f58a03eso5567431ejc.4 for <linux-mm@kvack.org>; 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=TSbxmmwD+OERO4vZPHeD0uAKvd8jQoukLgzo5nC4XW6jFWbKboNNH8NJDDyfyTUmF3 gVu4h+cBQwH2SdsXU6retA5Z9K1Qqzu0HCa26Nn3hA4VsKxfTAVmaKn3GrDnI3VITKMC DRXNm5SzmsoUPv/GpL6qshEpiiKgAgbbrLLg+pXZohXAZCqJ4ZzK/Am/7LOGdE/dkAzO Pbv192rzKTk6yVTViYgMRduJAKUEArNEy4EX8KrQA4j9mkkb/tTc8kdnkxG86g2oY059 H0BdfCh1rGMzjT+JSNTA/pykLwcEYulnCY0aoHfZC/FzpPBjLY40vl0TznehB+c+6jvy FyTw== X-Gm-Message-State: ACrzQf2qEdhTg2mnznvS8rA05QQC588lUvWbUfpDVYsEp1zBo5iiR5kQ BWuSgwdVTk631uhSxw1piD8l8Eufqqk= X-Google-Smtp-Source: AMsMyM75ouYEbc3+dMPfZoPiB6oSYiohoWcuheQnJIsz7c3U6au3f9s6axieNdPO5ybuRDS+Vorz5dq1hn0= 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 <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 Biggers <ebiggers@kernel.org>, 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>, Stephen Rothwell <sfr@canb.auug.org.au>, 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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663254380; a=rsa-sha256; cv=none; b=e/wuY617J4LIaf3val/8tRo4bgVilQscCEVdXjfk1joXBsqXSYQCGbvN48amxji5hdnIwN s0dWB5YpgJOZ7PnxsWOADBWUusGfvwFHNH7t+WdRAbBNb1dudZykNihOEeTh1q+pBG/gmv jbqYey7nprVpTVt3PTsGHYm5OpQrPEc= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=ERCi1CpV; spf=pass (imf03.hostedemail.com: domain of 3az8jYwYKCJY6B834H6EE6B4.2ECB8DKN-CCAL02A.EH6@flex--glider.bounces.google.com designates 209.85.218.74 as permitted sender) smtp.mailfrom=3az8jYwYKCJY6B834H6EE6B4.2ECB8DKN-CCAL02A.EH6@flex--glider.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663254380; 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=6C73Nm0py7Ay5pK+qQjL+VSb4Pfqd0+ONPbixRyW4vMOQFPH+kirhTt3jOimL/F0zLu55k naHCbykURCW6rWT7rZUJabHyTnqKj/zACfPnqBvrhuEUMjVeG0DlWIdIacFk9RJHt5TZaO RbzbgsVr7BoZXTANKO4mz+QVtTyofPc= Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=ERCi1CpV; spf=pass (imf03.hostedemail.com: domain of 3az8jYwYKCJY6B834H6EE6B4.2ECB8DKN-CCAL02A.EH6@flex--glider.bounces.google.com designates 209.85.218.74 as permitted sender) smtp.mailfrom=3az8jYwYKCJY6B834H6EE6B4.2ECB8DKN-CCAL02A.EH6@flex--glider.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: hby6so5qbtpze9fki3a6mp8xrguqkbag X-Rspamd-Queue-Id: B487C2009F X-HE-Tag: 1663254380-715617 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(-)