From nobody Wed Dec 17 21:41:09 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 58EFF1FCD0D for ; Sat, 21 Dec 2024 14:48:16 +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=1734792497; cv=none; b=BuYtsgdnczcEvAK3nmygpMj1UMsY0HVz/M3DyRoPExgFvRJCP5LqL0HJo16m1w/LKX18jyzver/c5QaXj5ZBs1yllZ1Frp7NdIayXI34Ypa+bBkwTskBKsJcA/Wex9fYB2WL+D851pHgXgyiOyOcE5KIB6ZYSKVhaUHfUYkFQvU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734792497; c=relaxed/simple; bh=N27SW5V9S6zkyqz00AIvVG+5Rix9h0ENrJDmGyAeG8A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tkIH8t7A768cjCXa2OzxtrEzk3pGbhflDH5en6/vH5YGpGnE/HB3o6YrC9Fu/gkhnN+6TLL1/r5oNsZyNU9NFBn3+Pfwccx29mJUkvSPQxfGB/hVjdX0TnJBvRnYTJB6BTSWagCTvt1v+yIDmkCS9DqfsoAW8Z+jKqPWg6u8E3Y= 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=Pdf7WZd/; 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="Pdf7WZd/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734792491; bh=N27SW5V9S6zkyqz00AIvVG+5Rix9h0ENrJDmGyAeG8A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Pdf7WZd/KEqFjEvas4FwWWeir8E5g7EOhTvWrqB6Nt5Gu7CTdpjO9Ura+5T4IfMLt 79ciGz484dD4DeYNJ7/Mm8SbIl7tGg92pmaX+PeYdxB7Fr3aUVuKpGIDsRIsijgPjq /Gk+HfDic2O9cqtQdvtU9/SBeSVcmxWo9/OKN7Gs= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 21 Dec 2024 15:48:12 +0100 Subject: [PATCH v2 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: <20241221-sysfs-const-bin_attr-misc-drivers-v2-6-ba5e79fe8771@weissschuh.net> References: <20241221-sysfs-const-bin_attr-misc-drivers-v2-0-ba5e79fe8771@weissschuh.net> In-Reply-To: <20241221-sysfs-const-bin_attr-misc-drivers-v2-0-ba5e79fe8771@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=1734792490; l=1571; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=N27SW5V9S6zkyqz00AIvVG+5Rix9h0ENrJDmGyAeG8A=; b=IXDM8dc7lVmDMCAr1wkZkdrRiZs8RT6lHIXepnbM8+omOaL1e1ocmfOreTcpfRPzfdnG4Wi1F Hu13Q87/KUkDiZYTf0ZJ3fg47IwdGmBMfJ0MrsUFJjIn6nchblbQVy6 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