From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-24.8 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0E73C43381 for ; Tue, 12 Jan 2021 13:34:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 34887230F9 for ; Tue, 12 Jan 2021 13:34:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 34887230F9 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 9D31B6B0202; Tue, 12 Jan 2021 08:34:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9833C6B0205; Tue, 12 Jan 2021 08:34:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 89B6A8D0090; Tue, 12 Jan 2021 08:34:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0252.hostedemail.com [216.40.44.252]) by kanga.kvack.org (Postfix) with ESMTP id 748B46B0202 for ; Tue, 12 Jan 2021 08:34:48 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 3ED1B362A for ; Tue, 12 Jan 2021 13:34:48 +0000 (UTC) X-FDA: 77697218256.17.rain47_280446f27515 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id 23C1E180D0185 for ; Tue, 12 Jan 2021 13:34:48 +0000 (UTC) X-HE-Tag: rain47_280446f27515 X-Filterd-Recvd-Size: 4724 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Tue, 12 Jan 2021 13:34:47 +0000 (UTC) Received: by mail-wr1-f44.google.com with SMTP id a12so2504637wrv.8 for ; Tue, 12 Jan 2021 05:34:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=z9FwHUycumOs6t3SGrgS7cCKPT7xvNasenz8IWyWKdE=; b=W+nxBakCaB7ynwGYftYLRdP83y1GTuxctzs44VzPtCtmSubuMVopEKdrenyngQtkEu V7P22CcfpoY+/Gn+4UtErhSHZXc7+8zeF6bSccwaJ1VPrTpV9pzT2btHTmIDR+8MomWa yuu5VMsycC/+yIIdCfzf11BkdzD4vdiLu4uWhAXGP3YmRoTpVsuhX2hEpFWK73RAJ37l P3dNktzINSGrOdq+QJrvOu+t9lGusgUz/2+dZiOZP6eKsPvQCqK28cxb9XxfFB2e0i0X WN5K1OvfuFbjh429mqP+FXlm0TscIb3gtLKQyc8hPIDJry3r8FcZDc48D3zDDiHzmXyl rEpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=z9FwHUycumOs6t3SGrgS7cCKPT7xvNasenz8IWyWKdE=; b=A6NnfNCaQgsd/GP5c3rIiS+Nty08ckBbdL7hvbUKH8l0vm/F5HtteisDQB+o6vByzf k3vVoNV//y8H5La2UNW/1GL3OSMLBhYmMgux0VcVOxEzMGlN26xZEBFTXb6VKOCPHDBi ha01PU6S9GY+5l8TkboBz5VbJrtsWGPOxm60C2ewhIBuLeVlNAf3m53ZCtCak3fTy56B TzZRvZ14Uh4Vli4U/q5PKBlaByQx3QujwmzukEtAxLR0np92qYICFtSjMGDQuqPg07I3 YrEjTI93rcfxP9GOrXhv7G6s60/SbD+9oMJVz8awkPM28MofaalDjLBgzXUjV6x/p8Dn 64tQ== X-Gm-Message-State: AOAM533TVG5oMJS6uovxXiK2eSQSI3VVrVAM8BiFVOFh3KA7J6dVuI97 KgLhvs88T84NFQRjq7md7CvX7Q== X-Google-Smtp-Source: ABdhPJyKyV9ETptwrtpI2ynczocJJyRkdU4fVd84RpDQb6jfsamTI8Mh/WaitaK3csy42ynajTMGag== X-Received: by 2002:a5d:6a88:: with SMTP id s8mr4508931wru.118.1610458486541; Tue, 12 Jan 2021 05:34:46 -0800 (PST) Received: from elver.google.com ([2a00:79e0:15:13:f693:9fff:fef4:2449]) by smtp.gmail.com with ESMTPSA id h184sm4218719wmh.23.2021.01.12.05.34.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jan 2021 05:34:45 -0800 (PST) Date: Tue, 12 Jan 2021 14:34:40 +0100 From: Marco Elver To: Andrey Konovalov Cc: Catalin Marinas , Vincenzo Frascino , Dmitry Vyukov , Alexander Potapenko , Andrew Morton , Will Deacon , Andrey Ryabinin , Evgenii Stepanov , Branislav Rankov , Kevin Brodsky , kasan-dev@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 07/11] kasan: add compiler barriers to KUNIT_EXPECT_KASAN_FAIL Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.0.2 (2020-11-20) 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: On Tue, Jan 05, 2021 at 07:27PM +0100, Andrey Konovalov wrote: > It might not be obvious to the compiler that the expression must be > executed between writing and reading to fail_data. In this case, the > compiler might reorder or optimize away some of the accesses, and > the tests will fail. > > Add compiler barriers around the expression in KUNIT_EXPECT_KASAN_FAIL. > > Signed-off-by: Andrey Konovalov > Link: https://linux-review.googlesource.com/id/I046079f48641a1d36fe627fc8827a9249102fd50 Reviewed-by: Marco Elver > --- > lib/test_kasan.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/lib/test_kasan.c b/lib/test_kasan.c > index dd3d2f95c24e..b5077a47b95a 100644 > --- a/lib/test_kasan.c > +++ b/lib/test_kasan.c > @@ -79,7 +79,9 @@ static void kasan_test_exit(struct kunit *test) > NULL, \ > &resource, \ > "kasan_data", &fail_data); \ > + barrier(); \ > expression; \ > + barrier(); \ > KUNIT_EXPECT_EQ(test, \ > fail_data.report_expected, \ > fail_data.report_found); \ > -- > 2.29.2.729.g45daf8777d-goog >