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 B65FA1FCF7C 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=1734792498; cv=none; b=UnXIxKxZRsqiBRsHiECWXT1PvRYUyQL5/HVPR0kXnFeCgOpKcEdCWl3CuHqyuXD2/nyPTQ/zw9qww2Xy73ZutpuDxj7CMPToLR3sN5Ct3QGiq+bpFi2nrl+opxsDRwy8TwUrOLLPsjopiK0u1DZYOHJrWcaS1VOOKK/0A/bsXoY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734792498; c=relaxed/simple; bh=K4ArLdURdX68J2n0OD7NKA61+TDFNtIXruvjgSApS6k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=d9dghQ2DE4IoIUCIWA0EB/HuRchpfHnwdN+Xkzsz1zQT2Ju9BdRUpNRpSpqOPgiTDNiZtjyEVcpALUOhMqixol3Ii2JerdMRQLTOvDLGlk/W9153Pmb3AxkxjoTc/vvZPo/kTb5f7himsxNxwJjb45g/5xQx520+EZLvusttFzc= 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=FHyHaGrB; 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="FHyHaGrB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734792491; bh=K4ArLdURdX68J2n0OD7NKA61+TDFNtIXruvjgSApS6k=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=FHyHaGrBeFnd6dXa1UhJKEN/Vj2M8u9k7KuCJeQBZ+TI0lgE+nsDb3YJJRQcRhln+ l6L7ImQUPv6oLtF9lGu0hab4fAk8lNt24Wank24BA7AIZuOZnjq20PP2zvp7LgZRr+ wk7d629uOMIHeU3wI3GWCxe3u9J23I95fIreojVo= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 21 Dec 2024 15:48:15 +0100 Subject: [PATCH v2 9/9] misc: ds1682: 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-9-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=1662; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=K4ArLdURdX68J2n0OD7NKA61+TDFNtIXruvjgSApS6k=; b=foEod6mMQTcekZkVuJkj3bgmnzgSH+ihxv0TERCRycmamIXRwEQekQx7aQLC9tnLABorA1EFH PCmFdNEgnGBArnWNitpNlMuNBREu/XWm0QXLKvsE2KCJdI/rKNR/fHA 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/ds1682.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/misc/ds1682.c b/drivers/misc/ds1682.c index 4175df7ef0111f69ed8d4229b7ab50a3c3d7ad12..5d5a70a62e98b6691aac1c0f914= 2d39555ba4f8c 100644 --- a/drivers/misc/ds1682.c +++ b/drivers/misc/ds1682.c @@ -154,7 +154,7 @@ static const struct attribute_group ds1682_group =3D { * User data attribute */ static ssize_t ds1682_eeprom_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, + const struct bin_attribute *attr, char *buf, loff_t off, size_t count) { struct i2c_client *client =3D kobj_to_i2c_client(kobj); @@ -172,7 +172,7 @@ static ssize_t ds1682_eeprom_read(struct file *filp, st= ruct kobject *kobj, } =20 static ssize_t ds1682_eeprom_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, + const struct bin_attribute *attr, char *buf, loff_t off, size_t count) { struct i2c_client *client =3D kobj_to_i2c_client(kobj); @@ -194,8 +194,8 @@ static const struct bin_attribute ds1682_eeprom_attr = =3D { .mode =3D S_IRUGO | S_IWUSR, }, .size =3D DS1682_EEPROM_SIZE, - .read =3D ds1682_eeprom_read, - .write =3D ds1682_eeprom_write, + .read_new =3D ds1682_eeprom_read, + .write_new =3D ds1682_eeprom_write, }; =20 static int ds1682_nvmem_read(void *priv, unsigned int offset, void *val, --=20 2.47.1