From patchwork Tue Oct 5 10:59:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Elver X-Patchwork-Id: 12536193 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3EBD8C433F5 for ; Tue, 5 Oct 2021 11:00:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E5434614C8 for ; Tue, 5 Oct 2021 11:00:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E5434614C8 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 73030940018; Tue, 5 Oct 2021 07:00:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 68F86940007; Tue, 5 Oct 2021 07:00:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4BCCF940018; Tue, 5 Oct 2021 07:00:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0180.hostedemail.com [216.40.44.180]) by kanga.kvack.org (Postfix) with ESMTP id 393F9940007 for ; Tue, 5 Oct 2021 07:00:31 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 02CB331ED8 for ; Tue, 5 Oct 2021 11:00:31 +0000 (UTC) X-FDA: 78662090262.02.887041B Received: from mail-qk1-f202.google.com (mail-qk1-f202.google.com [209.85.222.202]) by imf26.hostedemail.com (Postfix) with ESMTP id 9F74420061F2 for ; Tue, 5 Oct 2021 11:00:30 +0000 (UTC) Received: by mail-qk1-f202.google.com with SMTP id bk9-20020a05620a1a0900b0045df00f93a9so26660546qkb.1 for ; Tue, 05 Oct 2021 04:00:30 -0700 (PDT) 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=GLbylOcVG6Z3Pa9zRtQvvZApReh1K+etnDrS06Ovq3M=; b=FUiAxTnfrZLKUIMUnc8u8Uz1MPlAowbzXsoiyB0j1/uFmemd8bA57CbOJSvAnN0uer mWV43BDY51SWbpoWRR+8FYTzxCYDzgf2kQUkjcDeaLxzs60zcolLONh3I5/xSIM2Ln9a pDdOV/AOyMJZ3CEpBJr6cgi6t+sMmiweK3lQVUBfjP8KqZcObQKaWzLkMsOBi4PKrRwo pkWV19EvmTjKbCycM8POFEy7LjGI3rebQ+fKCwy2o+uP6loTZ5R2j48UcupzxzV7hZxz MydcwcR0hWw/EcEm6/tZbkG8TeBm5t0dYPdwTG1XyUWWYW6bL/e9ZkuFA9GL2O+TB21f /7GA== 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=GLbylOcVG6Z3Pa9zRtQvvZApReh1K+etnDrS06Ovq3M=; b=3vo5z5OeAaJQbREE/mn41DBOPLIVBEYREEsElW9WB/sl/1KQD0mazRWOBigeSvCbtO E8VRMVXKywvHOys2RZjNhKJRLa/oxHE/L3lLbUxrtnQ4yvHvb1zXwaziyCNEudP1uEGJ cN5YTIiRHZrge9IcWtXdlvj16FAIbSJ412/6SV96n5AqbWCj5PZ+7Y95KHZFThOv3KWk WTt73Zppy5mtfblrN6JmdSP7ZssfMdgPK6XR1ZZ+vMqfp+s9NmvSEKqkGfluBFWzqTIB LhqXsPdbRmyRgx2RmxajYiE04+luXMvCZhD+HdRh/4/wYA/0nQiOexifNNJYA9epw/vi 23xg== X-Gm-Message-State: AOAM532Q8IGOsk/fkGrdUL8LpnZtM0W7HS0QKoODVQ4ZfkQNYrWWh8r+ Bhx33uZD2lkd9iASwIzHLFXHyk3eGA== X-Google-Smtp-Source: ABdhPJyjNJ7xQvPokpErt/T0wlpwPwNSdSeEenve8kThGp3G7hepSph1caWrRWcNousw/8R5qeK+ovlydQ== X-Received: from elver.muc.corp.google.com ([2a00:79e0:15:13:e44f:5054:55f8:fcb8]) (user=elver job=sendgmr) by 2002:a0c:c1c9:: with SMTP id v9mr26722583qvh.31.1633431629848; Tue, 05 Oct 2021 04:00:29 -0700 (PDT) Date: Tue, 5 Oct 2021 12:59:02 +0200 In-Reply-To: <20211005105905.1994700-1-elver@google.com> Message-Id: <20211005105905.1994700-21-elver@google.com> Mime-Version: 1.0 References: <20211005105905.1994700-1-elver@google.com> X-Mailer: git-send-email 2.33.0.800.g4c38ced690-goog Subject: [PATCH -rcu/kcsan 20/23] 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 , Josh Poimboeuf , 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, x86@kernel.org Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=FUiAxTnf; spf=pass (imf26.hostedemail.com: domain of 3TTBcYQUKCDAQXhQdSaaSXQ.OaYXUZgj-YYWhMOW.adS@flex--elver.bounces.google.com designates 209.85.222.202 as permitted sender) smtp.mailfrom=3TTBcYQUKCDAQXhQdSaaSXQ.OaYXUZgj-YYWhMOW.adS@flex--elver.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 9F74420061F2 X-Stat-Signature: d13w4wcrjd5ns8umh9ukhgxyejgw1ac9 X-HE-Tag: 1633431630-205552 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 fc60a40ce954..11e9fcd410be 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