From nobody Wed Dec 17 21:40:55 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 BF810204591 for ; Mon, 16 Dec 2024 11:33:04 +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=1734348786; cv=none; b=bTw0SPt+LdI7+rH+Lm/39Y0ycQ4WnBX4RBc1Noy4CaUaui2ZtT/OTwoLyt7WKQduitCvMurHhq4gdELAhxzmTxnLMWsvQR6AEE1J0eEDbGH3PtA3l94oYcbDYy+sZrn06dpGzJPOyZIE3dcveo3KXqQfxg6AEjOoqAnwmlW+c5A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734348786; c=relaxed/simple; bh=N27SW5V9S6zkyqz00AIvVG+5Rix9h0ENrJDmGyAeG8A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tqpITFeuNZVISlT8K4nneiZZh7yU8Hav8GCNWGY6dXlCig84mzv+tWHm5NeFjoKV1XEBDoTtyX+YeG3s8BzeyQrnMq9FYnjVfSWC0YCJkMH3EPG9fX23pDz/a5ibswzLlks4RLST4dONcjKH+ZILwOBEHbUQH70La12sE9Iz3yk= 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=r7cZsmWq; 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="r7cZsmWq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734348782; bh=N27SW5V9S6zkyqz00AIvVG+5Rix9h0ENrJDmGyAeG8A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=r7cZsmWqkSHnWWTQwUfmtSM3avVaTLeMBQ+0ZIlNhWIb3YunB/5/WbAYBm3ILU8di Xg5Kpn6jYvHdLgxlAhONLCUPToOmQPQlA/IVbOEqHEybO5ppstUWToGUbWB+FyVaSN s6pY99uTMeTX248ff8x6WP/bndLS6dFjIYsIN6AQ= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 16 Dec 2024 12:33:01 +0100 Subject: [PATCH 6/9] misc: pch_phub: 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-misc-drivers-v1-6-d50ff7b21367@weissschuh.net> References: <20241216-sysfs-const-bin_attr-misc-drivers-v1-0-d50ff7b21367@weissschuh.net> In-Reply-To: <20241216-sysfs-const-bin_attr-misc-drivers-v1-0-d50ff7b21367@weissschuh.net> To: Frederic Barrat , Andrew Donnellan , Arnd Bergmann , Greg Kroah-Hartman Cc: linuxppc-dev@lists.ozlabs.org, 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=1734348781; l=1571; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=N27SW5V9S6zkyqz00AIvVG+5Rix9h0ENrJDmGyAeG8A=; b=Vg1WUEDQnr3nZOKV8hRgDVUS+4THPY1UyKWYauf/B9CFckAcJE3ZW1ijdp1vYL8eG0Zw7vmZE OJxRrEYRgIMCaPzGEyPSAJbwOZfPUTkjXzaNexouPQsjy0C9YaCO8qb 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/misc/pch_phub.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/misc/pch_phub.c b/drivers/misc/pch_phub.c index 8d2b7135738ed5543138f2249d2379a10113b410..6121c0940cd148d48b8d574065c= 50703b6a301d7 100644 --- a/drivers/misc/pch_phub.c +++ b/drivers/misc/pch_phub.c @@ -483,7 +483,7 @@ static int pch_phub_write_gbe_mac_addr(struct pch_phub_= reg *chip, u8 *data) } =20 static ssize_t pch_phub_bin_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, char *buf, + const struct bin_attribute *attr, char *buf, loff_t off, size_t count) { unsigned int rom_signature; @@ -553,7 +553,7 @@ static ssize_t pch_phub_bin_read(struct file *filp, str= uct kobject *kobj, } =20 static ssize_t pch_phub_bin_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, + const struct bin_attribute *attr, char *buf, loff_t off, size_t count) { int err; @@ -655,8 +655,8 @@ static const struct bin_attribute pch_bin_attr =3D { .mode =3D S_IRUGO | S_IWUSR, }, .size =3D PCH_PHUB_OROM_SIZE + 1, - .read =3D pch_phub_bin_read, - .write =3D pch_phub_bin_write, + .read_new =3D pch_phub_bin_read, + .write_new =3D pch_phub_bin_write, }; =20 static int pch_phub_probe(struct pci_dev *pdev, --=20 2.47.1