From patchwork Tue Nov 19 11:37:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Tesarik X-Patchwork-Id: 13879759 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 76934D44148 for ; Tue, 19 Nov 2024 11:39:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 16CE76B009B; Tue, 19 Nov 2024 06:39:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 11CB66B009E; Tue, 19 Nov 2024 06:39:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F27006B009F; Tue, 19 Nov 2024 06:39:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D85566B009B for ; Tue, 19 Nov 2024 06:39:04 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 8C781403A5 for ; Tue, 19 Nov 2024 11:39:04 +0000 (UTC) X-FDA: 82802646612.21.8B7015B Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) by imf11.hostedemail.com (Postfix) with ESMTP id 6846F4000A for ; Tue, 19 Nov 2024 11:38:00 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=suse.com header.s=google header.b=aEuE9+86; spf=pass (imf11.hostedemail.com: domain of ptesarik@suse.com designates 209.85.128.51 as permitted sender) smtp.mailfrom=ptesarik@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732016251; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=fVb/aba7kAugbNKh4JU+Sc2Vx3uCwvVw0Yr+o1yHZGI=; b=wC2N5AVMvLtupAHErIRXAo4L2TDqzxLX1yfhlLlMIzTLkO43LR1RzyxmD8YgkEHhVpwOdV Ob1k3pseKbeXEXeDYFQR3XelguC21zyMkUcVrtXMRCOCN9JKkOzEOslkACNmuzImzSGkkl ubr0UydppKsWU9VpSaBrQmSWM/mXrRQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732016251; a=rsa-sha256; cv=none; b=5OLOKaixlCkauIWrmX/ZwomgyZJTI8XBFeZIPpnyM7gGSiVluCBbeJCDZmLedoiW/1sVwb NHdJVdus4MRl0X+tbqtI9VORItIxJUecLfNB8dA9wMEKTN5WQsXYCyFI8rWuXx8AUTmt9V FZvatcv8grSyu4IJ4gqakiteuO8eP/k= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=suse.com header.s=google header.b=aEuE9+86; spf=pass (imf11.hostedemail.com: domain of ptesarik@suse.com designates 209.85.128.51 as permitted sender) smtp.mailfrom=ptesarik@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-431506d4f3bso3046975e9.0 for ; Tue, 19 Nov 2024 03:39:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1732016341; x=1732621141; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fVb/aba7kAugbNKh4JU+Sc2Vx3uCwvVw0Yr+o1yHZGI=; b=aEuE9+86nWzgD0RyDqJG9Fa5tEPFfugJtXJ2/qRAmToMU/bBJkOmekz85UxVyiyHqq 4X7t3rdc1I6FTVMrM42/4+d+MR2DKXEgkDpcmukoEq+VocVddxvUNLMuFfw9lUt5fGw1 NN6BJJrNwoGVQy6G7fmddM+R8AXilFT8ol3+/D/a3lQQMeUh7p1n5Nu9+t1y7xx7C0AE LX1YFiGy5/9cUolo89zA8C0dnHIBbqCOBvDerifYTwDY00kmCKS7nrvlleStuASEJlHK 3ebya5NDYgzi5skLrvnVCiFRI6/AjKCjpBWos4Sfgfkxq977d6Wl+jnK996PXR9ARfrE tLgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732016341; x=1732621141; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fVb/aba7kAugbNKh4JU+Sc2Vx3uCwvVw0Yr+o1yHZGI=; b=Y2GPbvVbXZi+b5G0REQ51+I9QpE45tpWYM729Hz1cygXY/sgtbLmI93oBtEVauWWQ2 XvbNZRJkm83lktd2vSCedeVEaP4FS37FScruXaG8F8Qru2RPGciEGLl1yNPUW7YINqHp zN886eoVRBWiVMWgW5f5BQqlEoQ8tOMj7Ykps2eeqA3ysXC0hSC6RIrFVu+d1wRi6mey omaEOG3FlsVh75dt3cJwPmdSgbMXVoLnXjmKrto3TVzzVcC1Wut3IkEnMNEPh6Kx0bkG J2QL05xpevrcBvoM1/syU/deEuD43FBU5ob0c07AC8wtXEFN0ybNrf1AGQvyogddnrUh IA4Q== X-Gm-Message-State: AOJu0Yz2/krUD+6i4N/qNuC5pGRYMqKrqxz8zn7/Y78EXHhIHKzqMndo g10J9KIhLsGQ2o1kvmehTyku92mM2ldo6xkX3O0hovMA/KuMuau3sfIAy4PcUi8= X-Google-Smtp-Source: AGHT+IFr45o9PycleaXFLiTzqXvscquGYb+Mn9zBNm7BOq5qHffbKvS1FuCE87Z0Yz6aN3Qi7Bsc1w== X-Received: by 2002:a05:600c:4eca:b0:431:5632:448d with SMTP id 5b1f17b1804b1-432df795cafmr57581345e9.9.1732016341354; Tue, 19 Nov 2024 03:39:01 -0800 (PST) Received: from localhost ([193.86.92.181]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432dab7878esm192965345e9.14.2024.11.19.03.39.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2024 03:39:00 -0800 (PST) From: Petr Tesarik To: Andrew Morton , Kees Cook , Jinbum Park Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Petr Tesarik Subject: [PATCH v2 1/2] mm/rodata_test: use READ_ONCE() to read const variable Date: Tue, 19 Nov 2024 12:37:38 +0100 Message-ID: <2a66dee010151b25cb143efb39091ef7530aa00a.1732016064.git.ptesarik@suse.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Server: rspam10 X-Stat-Signature: 5phh38hb46g1zsia4j3e7y761ig6kq31 X-Rspamd-Queue-Id: 6846F4000A X-Rspam-User: X-HE-Tag: 1732016280-372909 X-HE-Meta: U2FsdGVkX19anrLo4/e5xK4gfwWaexlY8VmZv52XBp4hzxrZ6Jf4kkk5sDfq4XyAu74xpsu+ab1czC7w9eI5SuXEOC+fW4d+fjNxUvQHuUyVBM/vJDcVH0KOO5FzXjBsaJd3UxO0wPucmQe2nI19NecnLztp1Jg917KvMyr/CkmBJ+4n2wQeOgV6b51f+OF7+rG4Y0mEQs2HFtrXCFiRXcwFZad0N1cATYlWuidzxGPQTMT5yLOQB82OQdvwABlp768HCz4NsQ/XE5fVzvoFifjFGQJC7Vg/P8nHaSdHdTCNB1piSOy7yJZc0/qjG6vFQEKer2VxwYGxu1Z/4k6EeP/8XYFh0py/ZArfi9voN50LTZDhEZfdPyocWuXayG9JI7QjtMODJ+CmjxOrH14hqYU7L60029+aH9FN1+ehZLpwuhDO4rgdgdXe2aJru7bQXNV601V9Gt8GBiVMEuAvi1Obr/s74Ncz0uWiVZhRSYThue0cJn9DkAWM2yk8v+P8WA2kR768apk/819no8AgBTZUW+TFjmBjkb5FbJTYEPodR3YOwwO0KItWZrbPOX61u7OMvgAubDxZm1iQmHjE/c2UvbdOap31YlxOoJZpHWmtBt7UtpwkgujSQPFrgMnHExqho0M1b9LNgckkuKFZ1U92s+J0HeTnW/asIzK7QasTMM3UpDwKSJGZBnaRkIdGmLjHkQPn9IWiKMVYGXdSinjl3t7L6M6IeyqwvLxt0w605MM/kjyGVDpV9vCudoa0DMxv/1sDE2P9NiSvpSPjkoFQrp9thaHdHYK2K9DF5s3YUi38iXe5uXuK7PmEZdRhdNjL4yzzjcOUftgTge2m6+Od+F5/ZuiLbLLCnGaOvPdpQu/YFqbHO/g969zlzU0OJrBDcfxgixv2WsIWnkyrx4y9xtVGxFlAbMZGm9165tRIv0FFGokUBOJRPE61f+xsVYR3O5Dhby9xAkTizZb M8Em6Jlq Zfpa4P1SL0xMW6yYca+M3rsF7awAefPlEybjvnldAncR/9tONCi8v7TSdV6y20T1EtxQpvqlrFsmks/uTmqShJC+szjKgG2eQ936F872FfhMnTOIId+H50n2bxtf8pftjQkk7OubOZOBhZgwE/rMb08Sea5tOh8FAFYmKETpDfJVc91InGXaj2ww/Y+PZACUwJEIeYII7HJ8zvGFqTgliYFrzTJf3PI9ME+cmnzshOwnAGP3asV3f7BOadvx4GmFMpK8Ajf9583Cvr2ZH0KJmIPkN+SqsDzct6ylBUuvaxxLzJ2QJdvd7ZWbvBhx2HEMLgpGOQrfn6By4h0Olmw7PycaXTwOqT7EIuIHsl4alFLWSL5zpnfWaz6DFPPbPo8rRCdcs3oqsDWyHNEI+O1E1V/IhCCnpljsm6HGCCYBkHDZW0gDTdToEKkHTxc2N26osly1k 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: List-Subscribe: List-Unsubscribe: The C compiler may optimize away the memory read of a const variable if its value is known at compile time. In particular, GCC14 with -O2 generates no code at all for test 1, and it generates the following x86_64 instructions for test 3: cmpl $195, 4(%rsp) je .L14 That is, it replaces the read of rodata_test_data with an immediate value and compares it to the value of the local variable "zero". Use READ_ONCE() to undo any such compiler optimizations and enforce a memory read. Fixes: 2959a5f726f6 ("mm: add arch-independent testcases for RODATA") Signed-off-by: Petr Tesarik --- mm/rodata_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/rodata_test.c b/mm/rodata_test.c index 6d783436951f..3b60425d80fe 100644 --- a/mm/rodata_test.c +++ b/mm/rodata_test.c @@ -20,7 +20,7 @@ void rodata_test(void) /* test 1: read the value */ /* If this test fails, some previous testrun has clobbered the state */ - if (!rodata_test_data) { + if (!READ_ONCE(rodata_test_data)) { pr_err("test 1 fails (start data)\n"); return; } @@ -33,7 +33,7 @@ void rodata_test(void) } /* test 3: check the value hasn't changed */ - if (rodata_test_data == zero) { + if (READ_ONCE(rodata_test_data) == zero) { pr_err("test data was changed\n"); return; } From patchwork Tue Nov 19 11:37:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Tesarik X-Patchwork-Id: 13879760 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 91B9FD4414C for ; Tue, 19 Nov 2024 11:39:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1E3026B009E; Tue, 19 Nov 2024 06:39:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 193306B009F; Tue, 19 Nov 2024 06:39:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E8AA26B00A0; Tue, 19 Nov 2024 06:39:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id CE8FE6B009E for ; Tue, 19 Nov 2024 06:39:05 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 79DC1ACC6C for ; Tue, 19 Nov 2024 11:39:05 +0000 (UTC) X-FDA: 82802647032.15.481527E Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) by imf28.hostedemail.com (Postfix) with ESMTP id 3D28EC0003 for ; Tue, 19 Nov 2024 11:38:11 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=suse.com header.s=google header.b=O68tCVOo; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf28.hostedemail.com: domain of ptesarik@suse.com designates 209.85.128.51 as permitted sender) smtp.mailfrom=ptesarik@suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732016209; a=rsa-sha256; cv=none; b=opn/1XuJvQH2gIAuCbGSvQz1+MzXXGal2/vv+kKcYHK+ONwHJidXI7ILwl3goim9VtzyHN D3axD94YXXsiLnAhrQwgPQanVp76DVyFrGxG9UTieseSHxDW8v5Qu9oqj2bi8BFJXNWP4K lVEb/cPH0Ox3bDfBiZO909w9DyztDso= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=suse.com header.s=google header.b=O68tCVOo; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf28.hostedemail.com: domain of ptesarik@suse.com designates 209.85.128.51 as permitted sender) smtp.mailfrom=ptesarik@suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732016209; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=lG1Omio8IVFrPBZwlyZ1caqZbGlQSUOI66Ha8ppX290=; b=5J2/T6nCdk+iHbDZUxhDum+cnwLV84IJygAdKKhDH0kxu/DT6sD8dI3Ru6dJtph9FXEGv2 6uYrYzUfTUUOnXmR26JG0QYN8ybM3Q4KJkkpk49rRSWeC1hLDcwTr08HV14R7QCMGZGTRA xyz/IhPzD5rnQmEpL/E0AnekEGY1VqI= Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4315ce4d250so3574775e9.2 for ; Tue, 19 Nov 2024 03:39:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1732016342; x=1732621142; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lG1Omio8IVFrPBZwlyZ1caqZbGlQSUOI66Ha8ppX290=; b=O68tCVOonzyLeLEDSLaOUU/AtnIEku1VXrjVUDUaSNoI6XA8lB7fW06Oqa7ldGwoDF fHmM6f1cQBVzEACqVttch0k6QWkxGCuo5MCAjbLe2nYVvXURqWMoAt24aKFt0N8jdYsO 2O2x1y9s6c+4DN1YrBXemS/DPcAfXIQdKfW/4zfLXOfRubIC0kOgBcerXi7hiu8Og96S FvdpBwuLdn8sbMbPljJ79MTethrrfqrJ065p4Lf5zfXPgLki1dbuufviVWJxyuHGryie 07N2mzNASYISyH2vUBa1WoIfXYhtummznf9AvRbcoi4ntzZlkVGhUQAqcnO6SBOthClc 7Kug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732016342; x=1732621142; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lG1Omio8IVFrPBZwlyZ1caqZbGlQSUOI66Ha8ppX290=; b=cwAzzc8W3yHtAWm55PMCym/4g/Kkd/HGkgJOVSD+Vj6VvEcSEIwg8gssqEqkujlaIc RuNORtnN5X4rVl8IB7hiK+VOxdaVkSvNp82JS7B48Giwdl8VPmucg+jbxiE9ghyhKFZV XrIDRnLG/mRO4AWKKEkZmNXzOuH6ZX9DRSULt0T2mYOejMQEXXvXBdfb+OvAU+ZyiaOR TQ/U8LKRC+NSklCQB9jLuVdHu0nPew3oQ4vfseA0hZhJH7sMqaTj1K9FKH2GmC5JRne5 pNWmWxa78bIMX1QF+ZhQj892NpMaZsH5nPCU8OP/NzsB4XHQTZLsYZBSyUlnok2LbT/y Xmgg== X-Gm-Message-State: AOJu0Yw6/6J9TZRd4y1BP/MdBUaoFYZEjYCqQNli1D09ysfzqVyvEDeo fvq5KtSKNXvIoGUiKcaHyCdohwww2+jXFe60ti9PjvDDnXnBDOyfyHFU84Q2AGM= X-Google-Smtp-Source: AGHT+IHe6Ej3iWlGns6ushsZHJY6uBzioMg6a5JbQcYzYab97s+KPixmL4yqtwSD1cB4PFDMg9dZtw== X-Received: by 2002:a05:600c:3ca8:b0:431:5316:6752 with SMTP id 5b1f17b1804b1-432df71e06fmr58418785e9.2.1732016342211; Tue, 19 Nov 2024 03:39:02 -0800 (PST) Received: from localhost ([193.86.92.181]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432dac1fbf9sm193085875e9.41.2024.11.19.03.39.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2024 03:39:01 -0800 (PST) From: Petr Tesarik To: Andrew Morton , Kees Cook , Jinbum Park Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Petr Tesarik Subject: [PATCH v2 2/2] mm/rodata_test: verify test data is unchanged, rather than non-zero Date: Tue, 19 Nov 2024 12:37:39 +0100 Message-ID: <386ffda192eb4a26f68c526c496afd48a5cd87ce.1732016064.git.ptesarik@suse.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 3D28EC0003 X-Stat-Signature: 3usjegfbsxjodg51xacufrpiyxqn44xr X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1732016291-133046 X-HE-Meta: U2FsdGVkX1/aCf3u0f7l6ExldO6RBgYGfDMHRgFFLYegbUBw3DtPQDnV77Z8StpahV2bh24q/uGRAQsniJMSy3DZOHqL1cw7IiHEwcDGKHYUFP2XY53UTQtJu1S8pk8HMsguWNl0m05ab3GLzC6+g/9JuAOotWFFlVB7x0pwt9vq4AiIaPi7thKES5jK4MEAIK5qM5v7KNlmml1UEP05vrivOJytFEGBNXzZRCEjhT1LdH9mFvQf3HFz2V5T00yRr+uuWxzbsIGp97cX1od39PI7tgfXIVMvI0p/LJOrHx4ixP//V+l9N3AN0BerSbB6jYFlfgXhvK+CraJXPPcb9IvVc0H+zJspzz8EaWyx209I/wIz4FtCHN23mzSnLI147Z70A85u8XfkPux6XkFpBLQAl5KM25zpDY0qB39Y8nT82ErYi9UNtoojespb+Fps0s3qXzZ5O+iVYaIVyJ5YRB7ydJq5yoYKphT77lwfu+oZmDmx6hoP4/jfqBApptZpddFnyeIaWOoQNr3TQvNc0uIe2FIm22JTGXXWyOkxJbwP4VXRAn98HuvH8MjZL2HFQ0C9Y299kVUmQxYwS+RqjMDE7dJSZLe+kesMI4bqgXwfADWhd/p/rMf0xKbAKh8SXgZAEHc2G8yKGCMlNf89B1P7QxsDHmyxBQoq/JJ7t8u0rLFqAtkF2FgSf6afPNa79h43t9gpA8jVYSamWfpEtODvNCQd4JPu546QIWibLNv6DKE5eXbfteIoYiNIUbFE5iqx/qXSexDtn5i8NHpX2LnSz+PkjdwjlGKyPp6W6Mq+cncTuJn6mDw9M10R2iSMN4hbIyOb+KHx9Kqha+F9VlPY3t5376hfkKciEaMfXxvBWqYXLflcJ8W0prtWngUom83b6J65SY5nUjSYXL/gY8GSrIcLIYMbSHhJO13QzPMWUXTzSrEwwmCLykUfal90z3kIpDAAFHnYXVzGSL0 /dsIcC5K smXylpg8w8O5OPYDRiDu3dGhbw+nRtLTd0KrkEddpiiGc0do60zC7hNyRsseYNIVVDA4ftRneCOQiS5+ne9W3JMZU0jT56L4Aww0hY3vawlteL71vxA9GU5lNfZJWpKglpJNGfRhWWXCcgrGV+5q9vtCxXHUi1pfFLYhXBjHLVy5gfvAVS6d76lHdIpzLw50emBmibi/TyBG4a1Kg2Y+WTUr+eYTHFLUdcKI8IxbedH2rP/SAWFJzlPuVGgF6TXKQBldAmLxzUPK7Mkn3smOnQ39p6iC3gnXCfq+i2u2KqnSZuhETUwMW3ukMABsTHGqvYIJ6C2RK4DAXkt6ZQcwX7eT2U2V12/wtXUHGszgUdT/8kbN3sWEO5vZcB4dr3rKC4TFakL5rHdGDMkp4NG8Zhqetj+/Fhle9pMaK8Kigfol/CJaNEQ3rC+yR1Sic3Hx9VMlI 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: List-Subscribe: List-Unsubscribe: Verify that the test variable holds the initialization value, rather than any non-zero value. Signed-off-by: Petr Tesarik --- mm/rodata_test.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/rodata_test.c b/mm/rodata_test.c index 3b60425d80fe..e7173fcd210c 100644 --- a/mm/rodata_test.c +++ b/mm/rodata_test.c @@ -12,7 +12,8 @@ #include #include -static const int rodata_test_data = 0xC3; +#define TEST_VALUE 0xC3 +static const int rodata_test_data = TEST_VALUE; void rodata_test(void) { @@ -20,7 +21,7 @@ void rodata_test(void) /* test 1: read the value */ /* If this test fails, some previous testrun has clobbered the state */ - if (!READ_ONCE(rodata_test_data)) { + if (unlikely(READ_ONCE(rodata_test_data) != TEST_VALUE)) { pr_err("test 1 fails (start data)\n"); return; } @@ -33,7 +34,7 @@ void rodata_test(void) } /* test 3: check the value hasn't changed */ - if (READ_ONCE(rodata_test_data) == zero) { + if (unlikely(READ_ONCE(rodata_test_data) != TEST_VALUE)) { pr_err("test data was changed\n"); return; }