From nobody Wed Dec 17 19:52:39 2025 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE8D8204563 for ; Mon, 16 Dec 2024 12:22:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734351780; cv=none; b=KTtGHqsPehVXJnixl/znedozdHXqs9uNygLl4bHXHhCCTjEmz1iqBpQFy+zF1GMBl4mCvK9rZyd5ab1kgCVb91Rz7Z+jn6oU4jVKCrcpxY8wRTxzal2jmn8lHv6VZhzb3k7y21/2VNaww1b1Kz9p6bOkpR0gvd2A9YS943bL+B0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734351780; c=relaxed/simple; bh=bsw1R3PrXav/ak1MSjYG8HxVy8MEpaINmTpeVmBaqYI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=uyLu3KbSOl51ROFvOY/QDnd2NzuoxuqHGJeHF+EPPrLtq4ex7eL5zA6bHt0k4/OhlYFAsr55t2s5aIi1S+wtxrD8Je0JqKPeF/42Jm2jWWKAPpc+MlTDjCbLUZ9Q7y3P8tVnFq3mP2szRLwwSUFZLNIxmytR6dmBqIcaHl/4lfE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=psT501tO; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="psT501tO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734351775; bh=bsw1R3PrXav/ak1MSjYG8HxVy8MEpaINmTpeVmBaqYI=; h=From:Date:Subject:To:Cc:From; b=psT501tOnGzdAWEYbEj1GYYHLZmjdM8bKTS0ohlEiDzemAiKcsHhC7w/3IdTnq4lg XELZ3XCy0IGLx4xZJdPvP5jr5lZ41fVGxqqtzJe6tDd5xnL9N3QNWpQwMH4tTSkhUG RIKzN0v2bHAHQQ1Ew2cz6pzGRY41HNhHTNJHhwdY= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 16 Dec 2024 13:22:54 +0100 Subject: [PATCH] rapidio: constify 'struct bin_attribute' Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241216-sysfs-const-bin_attr-rapidio-v1-1-0f47f4719683@weissschuh.net> X-B4-Tracking: v=1; b=H4sIAJ0bYGcC/x3MwQrCMAwA0F8ZORuwoQzdr4whsUs1l3YkZShj/ 27x+C7vABdTcZiGA0x2da2lI1wGSG8uL0Fdu4GuFAOFEf3r2THV4g2fWh7cmqHxpqtWjGO6x8S ZmG7Qi80k6+ffz8t5/gBNkn1QbgAAAA== X-Change-ID: 20241216-sysfs-const-bin_attr-rapidio-46c94caf2a28 To: Matt Porter , Alexandre Bounine Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734351775; l=2388; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=bsw1R3PrXav/ak1MSjYG8HxVy8MEpaINmTpeVmBaqYI=; b=U4r7DOgcxHNUUTd8qA2R89jzfPXiXai9oqt2W8yzvu8SK68VbmKU9kkxeEx82vVuIf+pAcwuk 9AWjux5OX85AP4UK7FNBML5XpBdEVN43i1EeyyXAPULeow9IWMOJcn8 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= 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=C3=9Fschuh --- drivers/rapidio/rio-sysfs.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/rapidio/rio-sysfs.c b/drivers/rapidio/rio-sysfs.c index 90d3912105338233b5f1cafc01fd499a77b66427..6f89b232f1d5d10a4dccf51422a= 57d4355ccf0c2 100644 --- a/drivers/rapidio/rio-sysfs.c +++ b/drivers/rapidio/rio-sysfs.c @@ -114,7 +114,7 @@ static struct attribute *rio_dev_attrs[] =3D { =20 static ssize_t rio_read_config(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { struct rio_dev *dev =3D to_rio_dev(kobj_to_dev(kobj)); @@ -185,7 +185,7 @@ rio_read_config(struct file *filp, struct kobject *kobj, =20 static ssize_t rio_write_config(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { struct rio_dev *dev =3D to_rio_dev(kobj_to_dev(kobj)); @@ -241,17 +241,17 @@ rio_write_config(struct file *filp, struct kobject *k= obj, return count; } =20 -static struct bin_attribute rio_config_attr =3D { +static const struct bin_attribute rio_config_attr =3D { .attr =3D { .name =3D "config", .mode =3D S_IRUGO | S_IWUSR, }, .size =3D RIO_MAINT_SPACE_SZ, - .read =3D rio_read_config, - .write =3D rio_write_config, + .read_new =3D rio_read_config, + .write_new =3D rio_write_config, }; =20 -static struct bin_attribute *rio_dev_bin_attrs[] =3D { +static const struct bin_attribute *const rio_dev_bin_attrs[] =3D { &rio_config_attr, NULL, }; @@ -278,7 +278,7 @@ static umode_t rio_dev_is_attr_visible(struct kobject *= kobj, static const struct attribute_group rio_dev_group =3D { .attrs =3D rio_dev_attrs, .is_visible =3D rio_dev_is_attr_visible, - .bin_attrs =3D rio_dev_bin_attrs, + .bin_attrs_new =3D rio_dev_bin_attrs, }; =20 const struct attribute_group *rio_dev_groups[] =3D { --- base-commit: 78d4f34e2115b517bcbfe7ec0d018bbbb6f9b0b8 change-id: 20241216-sysfs-const-bin_attr-rapidio-46c94caf2a28 Best regards, --=20 Thomas Wei=C3=9Fschuh