From patchwork Tue Jan 5 18:27:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 12000079 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=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT 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 903FFC433DB for ; Tue, 5 Jan 2021 18:31:45 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4391122D57 for ; Tue, 5 Jan 2021 18:31:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4391122D57 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:From:Subject:References:Mime-Version:Message-Id: In-Reply-To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6lbD7QXINH7CfU8/PjydzHqenD5H+4+hbr0X5BuQFk0=; b=ttAiPPkE3CSSHNAeBap2VA0YG bRJJgCDvXJlmO1b7L1hHT1sOEz8aLfTqSpbRYc3aqAxBG5SEJbOfbg7KO10USq6h/ZZbEnqY3L6Io 1mWZFD/uTab+zna2altY9ST33Xr5zDS2SJOVBMzevZhLClELDwxFC6wR10iLLC6PuNfFY94deBC+z dF9zrnGp651GSesy9E9rgVF3a+FEYDKct+4TqtJdTEXmoU+Rbw/VN0zo6GMxZxtwQStypl708nEAS Xzsacd4Wgojo2UszqnTTykscl6f342MONRKVRdTYPdLwi3xni+NAfg/4MplxQY9ntpvI1MThZdTSA kDZk8TPJA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kwr4l-0007Gx-Kk; Tue, 05 Jan 2021 18:28:59 +0000 Received: from mail-wr1-x44a.google.com ([2a00:1450:4864:20::44a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kwr4B-000736-Tb for linux-arm-kernel@lists.infradead.org; Tue, 05 Jan 2021 18:28:27 +0000 Received: by mail-wr1-x44a.google.com with SMTP id g17so183540wrr.11 for ; Tue, 05 Jan 2021 10:28:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=L2nfB5IDe6UR5zw3FZON/Z4AbH3dOVMSon2hvUv5xm8=; b=bRtGkcqXoe/bYVma5AcnnGEw1YbmPZW7e5RZXt5m1DN0wQ9mvEH4lwvMIKdWFu4pK0 gUbgLnCx+fZ9UPd+dvdcgg9Li0HTeBQOJLIaB+1EZgkC+J8Hqs5lDgOR5xNVOiBm26P3 jbqkhqEe7I2Ens74zeOsbOmJPbG/DNqEhlSfd3HTqf9FbJ/EsmPHLRmbu3in6OgZji8S /WW5QKCaOxuXsbSEuZ5ZuXa6BS7q2MwZcaNyQwhHpcPaGbcQ3zZpZYW84NWjyRw+5hqG xVADG0uids3vUoGlqxxeXHkD8gJeVLIyGbNVXR5qPlikY/okOEcDp1UK/bbzGd1wm0J2 7F4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=L2nfB5IDe6UR5zw3FZON/Z4AbH3dOVMSon2hvUv5xm8=; b=UnyXr7zXMVWOEOWuHl/piNAfF6GsShp2RZYS/qveBei+sKk5TWwa3zLx7maaznSN7Q yEVf5Cf3r0ci+Iu+H4DTaEnbvSY3ejOBdv0UnrIyzdBrG0QgO0JpzDStuVKe/icpXKcG Wz96dzM0xGq1ZYuP8hGThjZwDla2zEtukpobdFQSiJ+2QkINwIhauOq63E0NC0hGu8IW raL8cLxoYp3ok6Op069DtyxRwPQz733GJFFn5FDfA7WtqmaBsTqA0LLjXmNZq8+MOpVx tmaFOWX8fiSa62QfceLPDAITaSU1rHe4KBE4b/+DYKYDRrMGVQ0rp++bfWsqr9wp6Uf0 HHzw== X-Gm-Message-State: AOAM530/ekCoMOhX31aJ/6uxiF6HPC1XVzgEUOusS+tiqT9xHt1pM7aq 4UK+tgnHN/SeaEaEyVYz5o4oUwebY3PVlHGw X-Google-Smtp-Source: ABdhPJxm3lGUAgt1hjvEO/hnJ/HMsTuIHIRoW/Dg0H1aF9WW7wHG1xDYIpDPY8Dcc0/roDN0xvdsNxb67+kdPpfe X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:adf:f18a:: with SMTP id h10mr893184wro.244.1609871300796; Tue, 05 Jan 2021 10:28:20 -0800 (PST) Date: Tue, 5 Jan 2021 19:27:51 +0100 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.2.729.g45daf8777d-goog Subject: [PATCH 07/11] kasan: add compiler barriers to KUNIT_EXPECT_KASAN_FAIL From: Andrey Konovalov To: Catalin Marinas , Vincenzo Frascino , Dmitry Vyukov , Alexander Potapenko , Marco Elver X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210105_132824_073312_954517E7 X-CRM114-Status: GOOD ( 12.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Branislav Rankov , Andrey Konovalov , Kevin Brodsky , Will Deacon , linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, Andrey Ryabinin , Andrew Morton , Evgenii Stepanov Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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); \