From patchwork Tue Nov 30 11:44:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Elver X-Patchwork-Id: 12647101 Return-Path: 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 B2A26C433F5 for ; Tue, 30 Nov 2021 11:55:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 252D26B0095; Tue, 30 Nov 2021 06:46:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 202266B0096; Tue, 30 Nov 2021 06:46:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0D3D96B0098; Tue, 30 Nov 2021 06:46:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0137.hostedemail.com [216.40.44.137]) by kanga.kvack.org (Postfix) with ESMTP id F13F26B0095 for ; Tue, 30 Nov 2021 06:46:02 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id BA6D7824C42D for ; Tue, 30 Nov 2021 11:45:52 +0000 (UTC) X-FDA: 78865417386.26.2C574BD Received: from mail-qt1-f201.google.com (mail-qt1-f201.google.com [209.85.160.201]) by imf24.hostedemail.com (Postfix) with ESMTP id 4B78DB0000BC for ; Tue, 30 Nov 2021 11:45:47 +0000 (UTC) Received: by mail-qt1-f201.google.com with SMTP id v19-20020ac85793000000b002b19184b2bfso27019339qta.14 for ; Tue, 30 Nov 2021 03:45:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=rzdCErYR7QVJMqQ7C8iOEn+pKBOJL+BpLP2uqDT2sRI=; b=iiJU/NFxnkO4QpNuEziwm44ZddXcfbqTjJ27RND0XQcNYVVoxyYjAqEozptVgUXNwN tUotgFLhO6hTdCXy/8o38iy2aym7FJT+LW4h57+kXk+ITZwaPtmf/ukrKduYHtwrNNVy u6zRnFErKVJc5tA07nIb20yQJs/rjFgBkkJfiMGCJ0+/frkqjjvq7sB5Qlsbun/G1B3v mpVqufLXr0RiWnvRXu2PZPDLndJRxYoHPg3pEXSdStYWib1eEQIROpsu8lv6/UvQvgN4 KcSqzQSZ9rtkXbOEAqLYcx/YblyNiiImRh54NndbnYSq+4cJ1Y/85RKTI5bPUsrRqqxr ZZsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=rzdCErYR7QVJMqQ7C8iOEn+pKBOJL+BpLP2uqDT2sRI=; b=f7MRiN9i+CQD300f8NLqLYGwwmc991VcojZ5S3MH+OvzsHebdLuvAcH6LOTkxXdUtI w9kghr0hzyG/5wzBv0AREudJR+r/ghhPDzTHTMpPp6KVFeisKLdBMfeQxxEd7jaiPMPZ Sjy/IWJz+IRLIUA3d5mn8OXWt0M6OlpSTNaVn5jnKa0SMUXyn2t+n9v3I2+ibD+xefDp jNvPMjsIge3iW419pJx8hEeyBJxAWZbaUnoPhiuJWFgAZcc0yO5bMjopDVdEre8yBFDz EjhRR3jmDin8ssAw7VlKYz2QuyYAsvuS7BQIJi66EGlF6BTaW/S2KN5f7aFnN6NhkqZF bDAQ== X-Gm-Message-State: AOAM532g//sMjrDwHAUadiAupeQryDB3m+Blge5bCayCqVh4axKx//8o OwJpcGaNciG71TAb2rj6T7EXmX6toQ== X-Google-Smtp-Source: ABdhPJxS2DvHFjm5rRAa2Cv18Mr86xucn8I+904NmrEkNJGoQhVDVa+JTgno3MDa7PBFHMKHIzeyW8Gdjg== X-Received: from elver.muc.corp.google.com ([2a00:79e0:15:13:86b7:11e9:7797:99f0]) (user=elver job=sendgmr) by 2002:ac8:5c45:: with SMTP id j5mr51253786qtj.58.1638272751779; Tue, 30 Nov 2021 03:45:51 -0800 (PST) Date: Tue, 30 Nov 2021 12:44:28 +0100 In-Reply-To: <20211130114433.2580590-1-elver@google.com> Message-Id: <20211130114433.2580590-21-elver@google.com> Mime-Version: 1.0 References: <20211130114433.2580590-1-elver@google.com> X-Mailer: git-send-email 2.34.0.rc2.393.gf8c9666880-goog Subject: [PATCH v3 20/25] mm, kcsan: Enable barrier instrumentation From: Marco Elver To: elver@google.com, "Paul E. McKenney" Cc: Alexander Potapenko , Boqun Feng , Borislav Petkov , Dmitry Vyukov , Ingo Molnar , Mark Rutland , Peter Zijlstra , Thomas Gleixner , Waiman Long , Will Deacon , kasan-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, llvm@lists.linux.dev, x86@kernel.org X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 4B78DB0000BC X-Stat-Signature: jr14bobux9hmwd9i9yga1rtnwmagjnir Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="iiJU/NFx"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf24.hostedemail.com: domain of 37w6mYQUKCLgcjtcpemmejc.amkjglsv-kkitYai.mpe@flex--elver.bounces.google.com designates 209.85.160.201 as permitted sender) smtp.mailfrom=37w6mYQUKCLgcjtcpemmejc.amkjglsv-kkitYai.mpe@flex--elver.bounces.google.com X-HE-Tag: 1638272747-479739 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: Some memory management calls imply memory barriers that are required to avoid false positives. For example, without the correct instrumentation, we could observe data races of the following variant: T0 | T1 ------------------------+------------------------ | *a = 42; ---+ | kfree(a); | | | | b = kmalloc(..); // b == a <-+ | *b = 42; // not a data race! | Therefore, instrument memory barriers in all allocator code currently not being instrumented in a default build. Signed-off-by: Marco Elver --- mm/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/Makefile b/mm/Makefile index d6c0042e3aa0..7919cd7f13f2 100644 --- a/mm/Makefile +++ b/mm/Makefile @@ -15,6 +15,8 @@ KCSAN_SANITIZE_slab_common.o := n KCSAN_SANITIZE_slab.o := n KCSAN_SANITIZE_slub.o := n KCSAN_SANITIZE_page_alloc.o := n +# But enable explicit instrumentation for memory barriers. +KCSAN_INSTRUMENT_BARRIERS := y # 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