From patchwork Tue Mar 3 19:28:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qian Cai X-Patchwork-Id: 11418703 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 06B6B14BC for ; Tue, 3 Mar 2020 19:28:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BCF68208C3 for ; Tue, 3 Mar 2020 19:28:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lca.pw header.i=@lca.pw header.b="W392SK/v" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BCF68208C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lca.pw Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EE2166B0005; Tue, 3 Mar 2020 14:28:54 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E92156B0006; Tue, 3 Mar 2020 14:28:54 -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 DA74F6B000A; Tue, 3 Mar 2020 14:28:54 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0002.hostedemail.com [216.40.44.2]) by kanga.kvack.org (Postfix) with ESMTP id C0A856B0005 for ; Tue, 3 Mar 2020 14:28:54 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 38D338248D52 for ; Tue, 3 Mar 2020 19:28:54 +0000 (UTC) X-FDA: 76555038588.07.crowd35_6accd3e673500 X-Spam-Summary: 2,0,0,b549facd811ff549,d41d8cd98f00b204,cai@lca.pw,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1437:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3866:3867:3868:3870:3871:3872:3874:4250:4321:5007:6261:6653:8603:8660:10004:11026:11658:11914:12297:12438:12517:12519:12555:12895:13069:13148:13230:13311:13357:14018:14096:14181:14384:14394:14721:21080:21433:21444:21627:21966:30054:30079,0,RBL:209.85.222.193:@lca.pw:.lbl8.mailshell.net-62.14.0.100 66.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:60,LUA_SUMMARY:none X-HE-Tag: crowd35_6accd3e673500 X-Filterd-Recvd-Size: 3703 Received: from mail-qk1-f193.google.com (mail-qk1-f193.google.com [209.85.222.193]) by imf28.hostedemail.com (Postfix) with ESMTP for ; Tue, 3 Mar 2020 19:28:53 +0000 (UTC) Received: by mail-qk1-f193.google.com with SMTP id p62so4639675qkb.0 for ; Tue, 03 Mar 2020 11:28:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lca.pw; s=google; h=from:to:cc:subject:date:message-id; bh=qmv//PLMnUie9B7qaPX/qU2EmGiQx3aYNQaNo0ftsto=; b=W392SK/vElOUsNDyI6oHepG0UtGX6m0kYX6/Ow+4A6i7y0LVFCm1v+UBtAfyNJ9aXU DjP2f7Jg4CvPNJTx6RZL+hRzsqi9lvIOBjqkvqEqmF8+tqp7DEOZ5EDY0AUWkzl4ZLoP qqeAF9/nY+siFpQQcUQ9+H4PwygVUezWzgo212OOraDbStRhKECFfnV51wKzz/gpf5am V19kFvO8Rn4F7gtCw1otjZPiV5yXW5wyPzWYKD+V/yMKxHK1LMAHn/f3BAw4KnNluKp8 +lzv2mgJ50tJbCviVeOVdaaiZPAfb7zQ+SilPSVt2gW8COEko5S6x+hwbsFuIzJTsfzF syTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=qmv//PLMnUie9B7qaPX/qU2EmGiQx3aYNQaNo0ftsto=; b=KkvwzqgYFEMr35XjseuhYo70fE0UyfADtYMPfPOnQhktcAauRwiXN+1/fFFfmV1vbu TnOyY/AhSnLkcLMwx7ENeHXfYZ29eJabnlPEa4pCxnlIFglDs1zAFEEQ68HnsK2H71/a LGRyWAZQWuBt4WMpor5tzK2ExJtapfTjC8wOB+Rom4vK3+7kjPwEkVbgqk1A5096mCbO MIUCqtCOo6Jbx+vMq5Dh6g1dOg0swshf75J7CKZPP2DnP5E1OBxKQTgHGLkOYsSihtEz GloBBHmeb3xWOwEw+rEEZr6SgQYOY/vC1bHnNLQIt20vsSU7rnpuYZ62yMUz2/D0sujf /NUQ== X-Gm-Message-State: ANhLgQ0mhqi3ocm0LvUCdK37VfFkmfFpvtNHg6cpvZJAGU1mnUCdnNZ1 uLGNfSPpRgG81i7k2CTq07+IzA== X-Google-Smtp-Source: ADFU+vtdkDuYLw9tLxiNdRRm718gud7ooWVb+GAm8SnQTcSZTLUEJwlmx9EJniPmpYaDg+cSpfidqA== X-Received: by 2002:a05:620a:747:: with SMTP id i7mr5469399qki.375.1583263733297; Tue, 03 Mar 2020 11:28:53 -0800 (PST) Received: from qcai.nay.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id j7sm8872582qti.14.2020.03.03.11.28.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Mar 2020 11:28:52 -0800 (PST) From: Qian Cai To: akpm@linux-foundation.org Cc: elver@google.com, catalin.marinas@arm.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Qian Cai Subject: [PATCH -next 1/2] mm: disable KCSAN for kmemleak Date: Tue, 3 Mar 2020 14:28:35 -0500 Message-Id: <1583263716-25150-1-git-send-email-cai@lca.pw> X-Mailer: git-send-email 1.8.3.1 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000159, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Kmemleak could scan task stacks while plain writes happens to those stack variables which could results in data races. For example, in sys_rt_sigaction and do_sigaction(), it could have plain writes in a 32-byte size. Since the kmemleak does not care about the actual values of a non-pointer and all do_sigaction() call sites only copy to stack variables, just disable KCSAN for kmemleak to avoid annotating anything outside Kmemleak just because Kmemleak scans everything. Suggested-by: Marco Elver Signed-off-by: Qian Cai Acked-by: Marco Elver Acked-by: Catalin Marinas --- mm/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/Makefile b/mm/Makefile index 946754cc66b6..6e263045f0c2 100644 --- a/mm/Makefile +++ b/mm/Makefile @@ -14,6 +14,7 @@ KCSAN_SANITIZE_slab_common.o := n KCSAN_SANITIZE_slab.o := n KCSAN_SANITIZE_slub.o := n KCSAN_SANITIZE_page_alloc.o := n +KCSAN_SANITIZE_kmemleak.o := n # These files are disabled because they produce non-interesting and/or # flaky coverage that is not a function of syscall inputs. E.g. slab is out of From patchwork Tue Mar 3 19:28:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qian Cai X-Patchwork-Id: 11418705 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 8E11814BC for ; Tue, 3 Mar 2020 19:29:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5B000214DB for ; Tue, 3 Mar 2020 19:29:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lca.pw header.i=@lca.pw header.b="daGqKylB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5B000214DB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lca.pw Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A011F6B0006; Tue, 3 Mar 2020 14:29:01 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9D73B6B000A; Tue, 3 Mar 2020 14:29:01 -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 8C64A6B000C; Tue, 3 Mar 2020 14:29:01 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0189.hostedemail.com [216.40.44.189]) by kanga.kvack.org (Postfix) with ESMTP id 748426B0006 for ; Tue, 3 Mar 2020 14:29:01 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id DDBE28248D52 for ; Tue, 3 Mar 2020 19:29:00 +0000 (UTC) X-FDA: 76555038882.30.boys85_6bc3b6ba95352 X-Spam-Summary: 2,0,0,26a93b15e341cd0a,d41d8cd98f00b204,cai@lca.pw,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1359:1437:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:2693:3138:3139:3140:3141:3142:3352:3865:3867:3870:3872:4321:5007:6261:6653:8603:10004:11026:11658:11914:12043:12296:12297:12438:12517:12519:12555:12895:12986:13069:13311:13357:14018:14096:14181:14384:14394:14721:21080:21444:21627:21990:30054,0,RBL:209.85.219.68:@lca.pw:.lbl8.mailshell.net-66.100.201.201 62.2.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: boys85_6bc3b6ba95352 X-Filterd-Recvd-Size: 3947 Received: from mail-qv1-f68.google.com (mail-qv1-f68.google.com [209.85.219.68]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Tue, 3 Mar 2020 19:29:00 +0000 (UTC) Received: by mail-qv1-f68.google.com with SMTP id c19so2239023qvv.4 for ; Tue, 03 Mar 2020 11:28:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lca.pw; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5sB0rUv2y/FHn+2J4ke7VwpHWKH7r4gCKIkGyO1umgw=; b=daGqKylBIlAi05SY9J399ZZ2Y08VyEwEoo9tk80ZrcKcKxqZMlCtGyiYiZZO7BqhuT r69j/D9J4NoIk9x++Ba4c3nWXvLHE1CqqYXFJAwY0LNWoUwutCpjEEvtWhmZApPNcSB2 +vj+k2bNBUOvltMhLa4JkKJN89nFj/bopSPcetCwJE9kBjkGHYHi0t2m/fKFGfv4cIUf aktTqZjUm8o+5TSHHehGW1JANsTuhXMxv1wpv3Om+O87PS+uMIXh51l/nuKYg3Q5gb2z njXkMUxx4zFQMqjrlxwonYSv646HhRq/PdQEBz53X2RdFhelWAwYRSQ6S4Pz4Y3sy//w EWpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5sB0rUv2y/FHn+2J4ke7VwpHWKH7r4gCKIkGyO1umgw=; b=hRc4A4gvLd8iS9+54MHaskCno/92Yk3MQB7qUfE136QDip7u+6CVbZXrcY7Gszsklz tisAgKUIfReVxh5APLfF5uI2lwAQUMEtsnBi9Q2Q+O4gkRzu6Cz5E4KjqBSnp48UjhBa I1QhthSaU8VquSjMBKLCS9Qa8HOaxbA4x6LMto+n9+q92yvNCkVe9J1Vzx5Y+/fk03Dg XGtkaH/N5Oe5cdQL49FIpdClwPcWmNfcEQH4nDhBLsedEAEyaXRGUk96J5PnmEEIHJrO pOBpxSYl7G1CMklK1Dv0/8E4vr19Qri3y5PmdPY7qMXxGENtkbL+/l7ZqdVJQ4PGX8xE Pcdw== X-Gm-Message-State: ANhLgQ2sUzT1b+3rbTtLX1N97VkA+NdLqOCnO99+vyTstRWC0+e7UVf+ ygjRnkbEpEYeKnrnhQ54jAnd+g== X-Google-Smtp-Source: ADFU+vsdN08+hzzkYgx52slbfyXtJEtnMWJ/t/Xpb46+aEucSVYgw91EmssD2oQy1FgomzbaEwvJnA== X-Received: by 2002:ad4:4a6e:: with SMTP id cn14mr5364150qvb.21.1583263738513; Tue, 03 Mar 2020 11:28:58 -0800 (PST) Received: from qcai.nay.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id j7sm8872582qti.14.2020.03.03.11.28.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Mar 2020 11:28:58 -0800 (PST) From: Qian Cai To: akpm@linux-foundation.org Cc: elver@google.com, catalin.marinas@arm.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Qian Cai Subject: [PATCH -next 2/2] Revert "mm/kmemleak: annotate various data races obj->ptr" Date: Tue, 3 Mar 2020 14:28:36 -0500 Message-Id: <1583263716-25150-2-git-send-email-cai@lca.pw> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1583263716-25150-1-git-send-email-cai@lca.pw> References: <1583263716-25150-1-git-send-email-cai@lca.pw> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000008, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This reverts commit a03184297d546c6531cdd40878f1f50732d3bac9. Signed-off-by: Qian Cai Acked-by: Marco Elver Acked-by: Catalin Marinas --- mm/kmemleak.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/mm/kmemleak.c b/mm/kmemleak.c index 788dc5509539..e362dc3d2028 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -1169,12 +1169,7 @@ static bool update_checksum(struct kmemleak_object *object) u32 old_csum = object->checksum; kasan_disable_current(); - /* - * crc32() will dereference object->pointer. If an unstable value was - * returned due to a data race, it will be corrected in the next scan. - */ - object->checksum = data_race(crc32(0, (void *)object->pointer, - object->size)); + object->checksum = crc32(0, (void *)object->pointer, object->size); kasan_enable_current(); return object->checksum != old_csum; @@ -1248,7 +1243,7 @@ static void scan_block(void *_start, void *_end, break; kasan_disable_current(); - pointer = data_race(*ptr); + pointer = *ptr; kasan_enable_current(); untagged_ptr = (unsigned long)kasan_reset_tag((void *)pointer);