From patchwork Wed Oct 30 14:22:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 11219655 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 21710112B for ; Wed, 30 Oct 2019 14:24:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D482D20656 for ; Wed, 30 Oct 2019 14:24:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="foinEXrn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D482D20656 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6527A6B0288; Wed, 30 Oct 2019 10:24:05 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5DB7A6B028B; Wed, 30 Oct 2019 10:24:05 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A5086B028C; Wed, 30 Oct 2019 10:24:05 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0018.hostedemail.com [216.40.44.18]) by kanga.kvack.org (Postfix) with ESMTP id 233DA6B0288 for ; Wed, 30 Oct 2019 10:24:05 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id C9CA2181AEF31 for ; Wed, 30 Oct 2019 14:24:04 +0000 (UTC) X-FDA: 76100670408.03.pies67_40a4fa2e90048 X-Spam-Summary: 2,0,0,acf6be10b1cd2312,d41d8cd98f00b204,3ap25xqykcbc38501e3bb381.zb985ahk-997ixz7.be3@flex--glider.bounces.google.com,:arnd@arndb.de:monstr@monstr.eu:aryabinin@virtuozzo.com:vegard.nossum@oracle.com:dvyukov@google.com:rdunlap@infradead.org::viro@zeniv.linux.org.uk:akpm@linux-foundation.org:luto@kernel.org:ard.biesheuvel@linaro.org:hch@lst.de:dmitry.torokhov@gmail.com:edumazet@google.com:ericvh@gmail.com:gregkh@linuxfoundation.org:harry.wentland@amd.com:herbert@gondor.apana.org.au:mingo@elte.hu:axboe@kernel.dk:martin.petersen@oracle.com:schwidefsky@de.ibm.com:mst@redhat.com:pmladek@suse.com:sergey.senozhatsky@gmail.com:rostedt@goodmis.org:tiwai@suse.com:tytso@mit.edu:tglx@linutronix.de:wsa@the-dreams.de:gor@linux.ibm.com:iii@linux.ibm.com:mark.rutland@arm.com:willy@infradead.org:andreyknvl@google.com:elver@google.com:glider@google.com,RULES_HIT:41:152:355:379:541:800:960:973:988:989:1260:1277:1313:1314:1345:1359:1431:1437:1516:1518:1535:1542:1593:1594:1711:1730 :1747:17 X-HE-Tag: pies67_40a4fa2e90048 X-Filterd-Recvd-Size: 5958 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Wed, 30 Oct 2019 14:24:04 +0000 (UTC) Received: by mail-wm1-f73.google.com with SMTP id t203so933913wmt.7 for ; Wed, 30 Oct 2019 07:24:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=aEKImc3GyS6ol208UKSp/0U/bMelxB/cN8IdhVf0ZLU=; b=foinEXrn5sSIcguYqbpItfdFbBSQwUGgw7ZWYtog9jhutmhpGn/CP20f9ZRoWZU5d8 +in3hmNdMZEf4jSAuirGS+hY9tqzg1aVax2lbvIqeLiBqsGMEMdH9a9vcYskbzaPr7n5 0+ytUPoN8C2UEZ0hOblVYRxgFfIen19EYBdqUK3ez/e9Rzl1oTByL5487bav/5ems123 NH4RWdYkBeqbcq6hLED1Fgx8+K8umFXUdmvWx8rpVN6zsbng7V0RJvx/LQHjUDfCht4e 6dPFkmL0FHA6t6S/vpsgDeOlp8nlq9MFfNnuEII7akWB7J/Up1fAKKYBlo6lAYs3uvMY qTAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=aEKImc3GyS6ol208UKSp/0U/bMelxB/cN8IdhVf0ZLU=; b=ot7XmQu5Pg29Hmjtw6Z/mubQRNL4DrxpqDOsGpAYZL5Aww4jyl87se859NgQ36USLR w98qzJIXsE4vE6jWJvBls+v7du0lZjbjW7ViGwfUEB93gFtAe8DGAhnuYsHc2xPCVbkg T27I3JA8GBh+pVbCqIEWVeyL7pr5ycyTniXFKHU0La78FnjL5eaWQsaqc+/tU7/G0NTa Zf+a139RcRTidkBuh1UYLegX8wpdtM6+rT6nvhBEKJa07m6zN5cHP1D7Z7l0v8A+c43P nrICyZtt0wZxrEVZj7RN0iLM8LaxXd5qRAQEHVVEleCTCV/pNp7lGL8o7s0ueRmXdWlL QZpQ== X-Gm-Message-State: APjAAAXVjSjygDx8tUPcJWsz+pGZUmlthvmTwI9Qqqie8t0QApGXoGEE 4jZ61peZg+2nGNQQzoxzf51EhiM9BP8= X-Google-Smtp-Source: APXvYqwjPpcpgUP0Z97icCyzivmA96mht8GU52uWCfM2g0JpQRjExKg2Vw12ZjrmMQ96STLfojortXs+6R4= X-Received: by 2002:adf:ea88:: with SMTP id s8mr144262wrm.120.1572445442607; Wed, 30 Oct 2019 07:24:02 -0700 (PDT) Date: Wed, 30 Oct 2019 15:22:37 +0100 In-Reply-To: <20191030142237.249532-1-glider@google.com> Message-Id: <20191030142237.249532-26-glider@google.com> Mime-Version: 1.0 References: <20191030142237.249532-1-glider@google.com> X-Mailer: git-send-email 2.24.0.rc0.303.g954a862665-goog Subject: [PATCH RFC v2 25/25] net: kasan: kmsan: support CONFIG_GENERIC_CSUM on x86, enable it for KASAN/KMSAN From: glider@google.com To: Arnd Bergmann , Michal Simek , Andrey Ryabinin , Vegard Nossum , Dmitry Vyukov , Randy Dunlap , linux-mm@kvack.org Cc: viro@zeniv.linux.org.uk, akpm@linux-foundation.org, luto@kernel.org, ard.biesheuvel@linaro.org, hch@lst.de, dmitry.torokhov@gmail.com, edumazet@google.com, ericvh@gmail.com, gregkh@linuxfoundation.org, harry.wentland@amd.com, herbert@gondor.apana.org.au, mingo@elte.hu, axboe@kernel.dk, martin.petersen@oracle.com, schwidefsky@de.ibm.com, mst@redhat.com, pmladek@suse.com, sergey.senozhatsky@gmail.com, rostedt@goodmis.org, tiwai@suse.com, tytso@mit.edu, tglx@linutronix.de, wsa@the-dreams.de, gor@linux.ibm.com, iii@linux.ibm.com, mark.rutland@arm.com, willy@infradead.org, andreyknvl@google.com, elver@google.com, Alexander Potapenko 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: 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 To: Alexander Potapenko Cc: Arnd Bergmann Cc: Michal Simek Cc: Andrey Ryabinin Cc: Vegard Nossum Cc: Dmitry Vyukov Cc: Randy Dunlap Cc: linux-mm@kvack.org --- v2: - dropped the "default n" (as requested by Randy Dunlap) Change-Id: I645e2c097253a8d5717ad87e2e2df6f6f67251f3 --- arch/x86/Kconfig | 4 ++++ arch/x86/include/asm/checksum.h | 10 +++++++--- arch/x86/lib/Makefile | 2 ++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 6d2b0fb3a871..9ea394f6513a 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -272,6 +272,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 d79d1e622dcf..ab3464cbce26 100644 --- a/arch/x86/include/asm/checksum.h +++ b/arch/x86/include/asm/checksum.h @@ -1,6 +1,10 @@ /* SPDX-License-Identifier: GPL-2.0 */ -#ifdef CONFIG_X86_32 -# include +#ifdef CONFIG_GENERIC_CSUM +# include #else -# include +# ifdef CONFIG_X86_32 +# include +# else +# include +# endif #endif diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile index 5246db42de45..bca9031de9ff 100644 --- a/arch/x86/lib/Makefile +++ b/arch/x86/lib/Makefile @@ -55,7 +55,9 @@ endif lib-$(CONFIG_X86_USE_3DNOW) += mmx_32.o 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