From patchwork Fri Oct 18 09:43:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 11198017 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 A16FC18A6 for ; Fri, 18 Oct 2019 09:44:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6E97F20820 for ; Fri, 18 Oct 2019 09:44:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="AT8VyP2L" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6E97F20820 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 5E4AD8E0035; Fri, 18 Oct 2019 05:44:32 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 56E3F8E0003; Fri, 18 Oct 2019 05:44:32 -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 483A98E0035; Fri, 18 Oct 2019 05:44:32 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0097.hostedemail.com [216.40.44.97]) by kanga.kvack.org (Postfix) with ESMTP id 27E298E0003 for ; Fri, 18 Oct 2019 05:44:32 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id A3EDB182EE036 for ; Fri, 18 Oct 2019 09:44:31 +0000 (UTC) X-FDA: 76056420342.15.slope79_7ec7165eab361 X-Spam-Summary: 2,0,0,6f9d9f0aade35f99,d41d8cd98f00b204,3fympxqykccomrojkxmuumrk.iusrotad-ssqbgiq.uxm@flex--glider.bounces.google.com,:glider@google.com:arnd@arndb.de:monstr@monstr.eu:aryabinin@virtuozzo.com:vegard.nossum@oracle.com:dvyukov@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:1777:1792:1981:2194:2199:2393:2559:2562:3138:3139:3140:3141:3142:3152:3353:3865:3866:3867:3868:3871:3872:4250:4321:4605:5007:6120:6261:6653:7901:7904:9121:9969:10004:10400:10471:11026:11232:11473:11657:11658:11914:12043:12296:12297:12438:12555:12895:13255:13846:14096:14097:14181:14394:14659:14721:21080:21365:21444:21451:21627:30012:30041:30054:30064,0,RBL:209.85.128.73:@flex--glider.bounces.google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: slope79_7ec7165eab361 X-Filterd-Recvd-Size: 5173 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Fri, 18 Oct 2019 09:44:31 +0000 (UTC) Received: by mail-wm1-f73.google.com with SMTP id 190so2453740wme.4 for ; Fri, 18 Oct 2019 02:44:31 -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=MkrF0HFNZAmyt7YYXlDmiKQfJmn/DaWkPMYO97xCgaA=; b=AT8VyP2LiGwEKKeTKzmePGCkI7jdHxb8U2ZSXK79iKApxMPNTKXR9F5cnT7alnjURJ tByJjO34qgJ80o1DBQ6A7Zut4i9tn6SCesKX3lToN10rXaoRKrD2QR+WIzDbzzjnnlt7 o4XMHI1LmUP3lH03lUN218oWwt6NwgNnLw8pP2MLd19QT71k1uNsohCokZ3T7uB0hXe3 yIPIcPfXTd+N6kY/74+fs2nEabXbNxkQHBdeQwaekdd74MYf9pdlGomztq0aIeLAQjP+ TabeKDwLn+rGuIbcdwE9f24Hvu+nE0/rUC3IvzHLgy98Tfm7cnHpEOtpVRe2nwkBPzf8 1Wcw== 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=MkrF0HFNZAmyt7YYXlDmiKQfJmn/DaWkPMYO97xCgaA=; b=bdlR/NduASZBvW3Y2C+/Xh6AoSs9CMPtNk14ANuJw0WeB3COrko1SkRDCnHJRt0pZB ztEnYLMoZuBfOvTo/rOlrHlyGQCcs1hxvi0nRUs75qNzeTMLPlb6lBs+wfs622xas8ov 2r5LXUOsyHVsIqmHdEn2X1eNbliV0aMAJHZn+HvhJD4YPH6OH393bQZYC0I5xKB03BUK 3uqA2jCgWaqbLA23Qvv8LZj5ef6mha6fehxlI2T70w67Oq058t1J82spRW43q9Th7AYo SutP2SJNJNE2CC8UwX7Hzj6jXuQU4AIbgM8x/4kxBf7yKLv2N80iTDZVvmWDYz8CiWwq XgIA== X-Gm-Message-State: APjAAAWamQM8p9P5UCIIFfYi8WbABF64qWI6DHR3EJWsXR5cAiaulkvc NYMyRd/vb/mym9HWfTu6OAIjObTIYIU= X-Google-Smtp-Source: APXvYqzg1MOpLicaE0X+Iw5SmEmA896FkE9605iQtLcLLtCsJwBRPFctKJzyF33pWAKrgM01Ushu7Hr3KQU= X-Received: by 2002:adf:e5c4:: with SMTP id a4mr7205413wrn.334.1571391869987; Fri, 18 Oct 2019 02:44:29 -0700 (PDT) Date: Fri, 18 Oct 2019 11:43:04 +0200 In-Reply-To: <20191018094304.37056-1-glider@google.com> Message-Id: <20191018094304.37056-27-glider@google.com> Mime-Version: 1.0 References: <20191018094304.37056-1-glider@google.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog Subject: [PATCH RFC v1 26/26] net: kasan: kmsan: support CONFIG_GENERIC_CSUM on x86, enable it for KASAN/KMSAN From: glider@google.com To: Alexander Potapenko Cc: Arnd Bergmann , Michal Simek , Andrey Ryabinin , Vegard Nossum , Dmitry Vyukov , linux-mm@kvack.org 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: linux-mm@kvack.org --- Change-Id: I645e2c097253a8d5717ad87e2e2df6f6f67251f3 --- arch/x86/Kconfig | 5 +++++ arch/x86/include/asm/checksum.h | 10 +++++++--- arch/x86/lib/Makefile | 2 ++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 6d2b0fb3a871..dfec655d1a7a 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -272,6 +272,11 @@ config GENERIC_ISA_DMA def_bool y depends on ISA_DMA_API +config GENERIC_CSUM + bool + default y if KMSAN || KASAN + default n + 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