From patchwork Fri Nov 22 11:26:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 11257929 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 6695C6C1 for ; Fri, 22 Nov 2019 11:28:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1964B20672 for ; Fri, 22 Nov 2019 11:28:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="eqUij8CB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1964B20672 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 2BEE26B0505; Fri, 22 Nov 2019 06:28:21 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 224786B0507; Fri, 22 Nov 2019 06:28:21 -0500 (EST) 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 10F4F6B0508; Fri, 22 Nov 2019 06:28:21 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0224.hostedemail.com [216.40.44.224]) by kanga.kvack.org (Postfix) with ESMTP id EF4A26B0505 for ; Fri, 22 Nov 2019 06:28:20 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id AEEA58249980 for ; Fri, 22 Nov 2019 11:28:20 +0000 (UTC) X-FDA: 76183689960.29.train73_e9572df8b323 X-Spam-Summary: 2,0,0,6519a115e76a920d,d41d8cd98f00b204,3usbxxqykcdmvaxstgvddvat.rdbaxcjm-bbzkprz.dgv@flex--glider.bounces.google.com,:arnd@arndb.de:monstr@monstr.eu:aryabinin@virtuozzo.com:vegard.nossum@oracle.com:dvyukov@google.com:rdunlap@infradead.org::glider@google.com:viro@zeniv.linux.org.uk:adilger.kernel@dilger.ca:akpm@linux-foundation.org:andreyknvl@google.com:luto@kernel.org:ard.biesheuvel@linaro.org:hch@infradead.org:hch@lst.de:darrick.wong@oracle.com:davem@davemloft.net:dmitry.torokhov@gmail.com:ebiggers@google.com:edumazet@google.com:ericvh@gmail.com:gregkh@linuxfoundation.org:harry.wentland@amd.com:herbert@gondor.apana.org.au:iii@linux.ibm.com:mingo@elte.hu:jasowang@redhat.com:axboe@kernel.dk:m.szyprowski@samsung.com:elver@google.com:mark.rutland@arm.com:martin.petersen@oracle.com:schwidefsky@de.ibm.com:willy@infradead.org:mst@redhat.com:pmladek@suse.com:cai@lca.pw:robin.murphy@arm.com:sergey.senozhatsky@gmail.com:rostedt@goodmis.org:tiwai@suse.com:tytso@mit.edu :tglx@li X-HE-Tag: train73_e9572df8b323 X-Filterd-Recvd-Size: 6132 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Fri, 22 Nov 2019 11:28:20 +0000 (UTC) Received: by mail-wr1-f74.google.com with SMTP id e3so3714060wrs.17 for ; Fri, 22 Nov 2019 03:28:19 -0800 (PST) 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=PTJpK6SKxUEKa/uIhvdTxKkAhIwgw3SUMpq/6CKFry4=; b=eqUij8CBeYTy+1M5AUNlSY9qps8WN9lijxMmPNG5DhtQRyMhiEt9izS0Wa+6JcxoDt YfnlHamTgfSCBPh3o3AszeIdEzrxx8yT13XdRqleqQMFsUxnzZTJFkZRfGCP9CUha2eK cMo7z2LCOYdsVoVPn1nzhZO+/XMdxBwbQpy5WDrYK3SFWZ69nMTzsC0n092vWP8tA6JV Et9ux4nPTIxzDRsnagMs8h36bOB7N4/FVfxp/UMluMLIuX4Vyub+0QZrCj63mRImMv0C FDMOX4AWQ+R5vG5J3cNVox9u3ZyKPc2i7rlIra27xNW4TN1rlZTT/Zea0tkcaAOXHvWT khpw== 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=PTJpK6SKxUEKa/uIhvdTxKkAhIwgw3SUMpq/6CKFry4=; b=czLRFn5XqG04Tw8+WsjDmdlqgSwYxgSi2Rci5wEStGyCovgwhtrbcroGxPpKVx3o9B 8vFCvmBWNgGmu2y7Bp0cHxTp4lo2QyNrL+6Ri9GbnZ+NIRZblfTk+aOzhiGqxaQzd84Y 5sZ6bVXdppflGgCg0IJ66M6hvdsD9kutzH8CBeUY9r54zFyfNHcKX9fWQrUd3DlBhkHG V2ZCcvfS6AZpMdbV2fEy3N/LKXl6pmSDi7ta7FZetGsmJEPBuIpBe85wPGatGBPega4m C9DLf2+3gPSdynIGc2EfrQi6KpLcGVT3jG/4YDuWoeDaBsWeZk7hFFoCOVVXk6CnEqU3 saHA== X-Gm-Message-State: APjAAAUAJUEJAZpWFwvWxlnL8U92UMbqPSBSXGpeFdIGpkUKh3yQmHm5 dqs/Ky04WblQQG8dAZ5RQetFN/rWZXw= X-Google-Smtp-Source: APXvYqx+1O1u0CASeACWDP85c3BBPYCItfwV2vFTTVNOzRinf3IrY1zx/XkSyepVHiD+5Ojz/TAP2AzBQco= X-Received: by 2002:adf:e301:: with SMTP id b1mr16895799wrj.280.1574422098649; Fri, 22 Nov 2019 03:28:18 -0800 (PST) Date: Fri, 22 Nov 2019 12:26:21 +0100 In-Reply-To: <20191122112621.204798-1-glider@google.com> Message-Id: <20191122112621.204798-37-glider@google.com> Mime-Version: 1.0 References: <20191122112621.204798-1-glider@google.com> X-Mailer: git-send-email 2.24.0.432.g9d3f5f5b63-goog Subject: [PATCH RFC v3 36/36] 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: glider@google.com, viro@zeniv.linux.org.uk, adilger.kernel@dilger.ca, akpm@linux-foundation.org, andreyknvl@google.com, luto@kernel.org, ard.biesheuvel@linaro.org, hch@infradead.org, hch@lst.de, darrick.wong@oracle.com, davem@davemloft.net, dmitry.torokhov@gmail.com, ebiggers@google.com, edumazet@google.com, ericvh@gmail.com, gregkh@linuxfoundation.org, harry.wentland@amd.com, herbert@gondor.apana.org.au, iii@linux.ibm.com, mingo@elte.hu, jasowang@redhat.com, axboe@kernel.dk, m.szyprowski@samsung.com, elver@google.com, mark.rutland@arm.com, martin.petersen@oracle.com, schwidefsky@de.ibm.com, willy@infradead.org, mst@redhat.com, pmladek@suse.com, cai@lca.pw, robin.murphy@arm.com, sergey.senozhatsky@gmail.com, rostedt@goodmis.org, tiwai@suse.com, tytso@mit.edu, tglx@linutronix.de, gor@linux.ibm.com, wsa@the-dreams.de 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 3f83a5c53808..f497aae3dbf4 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