From patchwork Mon Dec 16 12:20:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13909648 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 0EA16E7717F for ; Mon, 16 Dec 2024 12:20:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F8406B0082; Mon, 16 Dec 2024 07:20:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A85B6B0088; Mon, 16 Dec 2024 07:20:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 56FB16B0089; Mon, 16 Dec 2024 07:20:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 39BE46B0082 for ; Mon, 16 Dec 2024 07:20:34 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id DBBE9448C5 for ; Mon, 16 Dec 2024 12:20:33 +0000 (UTC) X-FDA: 82900729506.24.32EBE56 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by imf30.hostedemail.com (Postfix) with ESMTP id 7D02E8000B for ; Mon, 16 Dec 2024 12:19:35 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=weissschuh.net header.s=mail header.b="j/wMSdQd"; spf=pass (imf30.hostedemail.com: domain of linux@weissschuh.net designates 159.69.126.157 as permitted sender) smtp.mailfrom=linux@weissschuh.net; dmarc=pass (policy=quarantine) header.from=weissschuh.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734351612; 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-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=VYnOYDRm3bHyF7C/SE5ECG3D1o+2ziXwvAPCT/v0/UU=; b=eV92w9XzlMAz+hPjYT0savPIHoesOKcpOv1X3igxZzJddqtxViemMNdckppGikNPD+Wzsr 4+ALcarM2l1a3UxukZwPomRfcxJsM1bhCrVPbrzelq6iYfnya5AK2iBEKcxJyt7zI0XuQy MGe6GUDmZ3rUqOVbQyDGuwhF6DVqBds= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=weissschuh.net header.s=mail header.b="j/wMSdQd"; spf=pass (imf30.hostedemail.com: domain of linux@weissschuh.net designates 159.69.126.157 as permitted sender) smtp.mailfrom=linux@weissschuh.net; dmarc=pass (policy=quarantine) header.from=weissschuh.net ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734351612; a=rsa-sha256; cv=none; b=KoecJvsgmsaa2F0CvDmNP9q3/YDYfKJ7l5agEu/jlWsmZtEjWyzVzYUsJ9jNHslJFPu73e 5+a/D8zVSxEVMXzMeGlPCxiNEleE/uRpuZLzlXA0zmceavtcreKGHMz9KZL0xLbPPrUPhr DfO47AUz5CrUPu1vg65VyfqL3t0ti50= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734351628; bh=6uSzS295pBUph9/CaqG8BNCeLzLkb5Xo0dFAAPEqQAI=; h=From:Date:Subject:To:Cc:From; b=j/wMSdQdDGGFIzx0EsKaPKVvzdrbfybSr8XN5+ubf30Z0VpxqWk8m+s/Z6np1Zagb BrIruhNYbv8Dz8C4IikA4iTTAbtVtinJ8EAsCCPC/hOhVBP/Vxtzd7E3Kq1FDxrLKZ wBEmKtO2D87rKXIQdiFGcOG3hCmnKiBHiYev7t1s= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 16 Dec 2024 13:20:25 +0100 Subject: [PATCH] mm/page_idle: Constify 'struct bin_attribute' MIME-Version: 1.0 Message-Id: <20241216-sysfs-const-bin_attr-page_idle-v1-1-cc01ecc55196@weissschuh.net> X-B4-Tracking: v=1; b=H4sIAAgbYGcC/x3NQQqDMBBG4avIrDtgglrsVUoJUf/YAYmSCdIi3 t3g8tu8d5AiCZRe1UEJu6isscA8Khq/Ps5gmYrJ1rYx1nSsfw3K4xo18yDR+ZwTb36Gk2kBt/B Dhx7POgQqkS0hyO8evD/neQFRxlU1cAAAAA== X-Change-ID: 20241216-sysfs-const-bin_attr-page_idle-5eab6e9e70ff To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei?= =?utf-8?q?=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734351627; l=2099; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=6uSzS295pBUph9/CaqG8BNCeLzLkb5Xo0dFAAPEqQAI=; b=sSim89Ek+/uC5QVd1ArbYMoQroruCbMMnZhJ0yx4TrtO6A5rtACkY3y/xeO6kDGF7KhKkdnSj ykCcV1XTL/qCU7lrHaYDx/OLG+XChsgtW6/IXafZhjzeqKRfueekR6z X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= X-Rspamd-Server: rspam05 X-Stat-Signature: 8793wge8fzamkk6si98bi8ooruxsnxya X-Rspamd-Queue-Id: 7D02E8000B X-Rspam-User: X-HE-Tag: 1734351575-324457 X-HE-Meta: U2FsdGVkX18aBMu+y+zzfsHgItbFOpyGTTkZpqh7s0FO6UtBlY8eEeq7V0M7mD+9dsrodvPBZHcyw6Nlr6MVt82kRo3ePP7fL3zhu/oEaU7ZwJhszraChIRE6NPoe23nDaYDEbMqyxXuR4Q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AKuHVOObmIzHLa4NBG6vAXEUDnhl1Ka7B+pi9tWsVTGOtadOsydbtxC1FF/tScFLx/kYUw== 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 sysfs core now allows instances of 'struct bin_attribute' to be moved into read-only memory. Make use of that to protect them against accidental or malicious modifications. Signed-off-by: Thomas Weißschuh --- mm/page_idle.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- base-commit: 78d4f34e2115b517bcbfe7ec0d018bbbb6f9b0b8 change-id: 20241216-sysfs-const-bin_attr-page_idle-5eab6e9e70ff Best regards, diff --git a/mm/page_idle.c b/mm/page_idle.c index 41ea77f22011ebc88cd0fe1e40abad6d11ff9b08..947c7c7a37289ad386f140047f733d4388833546 100644 --- a/mm/page_idle.c +++ b/mm/page_idle.c @@ -112,7 +112,7 @@ static void page_idle_clear_pte_refs(struct folio *folio) } static ssize_t page_idle_bitmap_read(struct file *file, struct kobject *kobj, - struct bin_attribute *attr, char *buf, + const struct bin_attribute *attr, char *buf, loff_t pos, size_t count) { u64 *out = (u64 *)buf; @@ -157,7 +157,7 @@ static ssize_t page_idle_bitmap_read(struct file *file, struct kobject *kobj, } static ssize_t page_idle_bitmap_write(struct file *file, struct kobject *kobj, - struct bin_attribute *attr, char *buf, + const struct bin_attribute *attr, char *buf, loff_t pos, size_t count) { const u64 *in = (u64 *)buf; @@ -193,17 +193,17 @@ static ssize_t page_idle_bitmap_write(struct file *file, struct kobject *kobj, return (char *)in - buf; } -static struct bin_attribute page_idle_bitmap_attr = +static const struct bin_attribute page_idle_bitmap_attr = __BIN_ATTR(bitmap, 0600, page_idle_bitmap_read, page_idle_bitmap_write, 0); -static struct bin_attribute *page_idle_bin_attrs[] = { +static const struct bin_attribute *const page_idle_bin_attrs[] = { &page_idle_bitmap_attr, NULL, }; static const struct attribute_group page_idle_attr_group = { - .bin_attrs = page_idle_bin_attrs, + .bin_attrs_new = page_idle_bin_attrs, .name = "page_idle", };