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; }