From nobody Sun Dec 14 13:49:28 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 CC5921FF1CB for ; Wed, 11 Dec 2024 17:50:26 +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=1733939429; cv=none; b=sIm6gyrsRnl3YuUP3vg+Ave1AQVhx8lR+IO/XdAnuKqd9IFF9dwWWDOf7mcf8CfSdyE/GqTbQ7U+qVv9qgfsyIHaOonBK2BtRI/X7O2k8iu1vYGMq4dHfUfiQeLe5J0sEoknmroqkcq6psqfpBS6BkbTJ79/hDuq2+Vw4bOZQjw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733939429; c=relaxed/simple; bh=bUyjneqJ82qE5Q2Egopw9U+eU3xunsYhHtD2ie3mmk8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Wo7al96Ihz3hXQy9xCzGvbR6JmeO51juHCrTwJhgn0zIXRyQw7JlZ2t8QCPQXefEG4mDdGmC+n74KbdzgTqneH88uES1XoDDup34ozlorTRWB3dhKfne7CYpqS2K1Y9+hsIfpYkyxZU1MHPQGtIY07tGw0uNI43b9q+W6Er/gw4= 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=im1eIwNn; 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="im1eIwNn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733939418; bh=bUyjneqJ82qE5Q2Egopw9U+eU3xunsYhHtD2ie3mmk8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=im1eIwNnwsh8MMLIExg0wHJPZDpx5LjBmfm7cPoH51b6WQq6Q/ok/e5cUv/hbsU6U +FqLWDIpfzcMi3V7irAY9Wa7FgMmyPAzAoiwiiuLrtCcmyh8PSD5xh0bOiWsx8SXed CK7hy8pdfpEJZ5WhjMAtOXKVX95gGXqqVmrMKa0o= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 11 Dec 2024 18:50:16 +0100 Subject: [PATCH 01/12] w1: 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: <20241211-sysfs-const-bin_attr-w1-v1-1-c4befd2aa7cc@weissschuh.net> References: <20241211-sysfs-const-bin_attr-w1-v1-0-c4befd2aa7cc@weissschuh.net> In-Reply-To: <20241211-sysfs-const-bin_attr-w1-v1-0-c4befd2aa7cc@weissschuh.net> To: Krzysztof Kozlowski 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=1733939417; l=1851; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=bUyjneqJ82qE5Q2Egopw9U+eU3xunsYhHtD2ie3mmk8=; b=qiT2xdoVK6rzPO+5T0xUR2tWN6luxWoaCaiaT8kMD2UmLlybHwKKPz6Lk+udvI62SGltDfRFn txQViJKz0czC/EuP0YFP7MvoIsNDGNsHfm1JbXSTa6bh5V4wMOB+iY0 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/w1/w1.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index d82e86d3ddf6429878a50bd9418845ee57667ae1..29f200bbab41f41948388635e0f= 1790ec39ca417 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c @@ -111,7 +111,7 @@ ATTRIBUTE_GROUPS(w1_slave); /* Default family */ =20 static ssize_t rw_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, loff_t off, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { struct w1_slave *sl =3D kobj_to_w1_slave(kobj); @@ -130,8 +130,8 @@ static ssize_t rw_write(struct file *filp, struct kobje= ct *kobj, } =20 static ssize_t rw_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, loff_t off, - size_t count) + const struct bin_attribute *bin_attr, char *buf, + loff_t off, size_t count) { struct w1_slave *sl =3D kobj_to_w1_slave(kobj); =20 @@ -141,15 +141,15 @@ static ssize_t rw_read(struct file *filp, struct kobj= ect *kobj, return count; } =20 -static BIN_ATTR_RW(rw, PAGE_SIZE); +static const BIN_ATTR_RW(rw, PAGE_SIZE); =20 -static struct bin_attribute *w1_slave_bin_attrs[] =3D { +static const struct bin_attribute *const w1_slave_bin_attrs[] =3D { &bin_attr_rw, NULL, }; =20 static const struct attribute_group w1_slave_default_group =3D { - .bin_attrs =3D w1_slave_bin_attrs, + .bin_attrs_new =3D w1_slave_bin_attrs, }; =20 static const struct attribute_group *w1_slave_default_groups[] =3D { --=20 2.47.1 From nobody Sun Dec 14 13:49:28 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 CC6171FF1D0 for ; Wed, 11 Dec 2024 17:50:26 +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=1733939430; cv=none; b=e/3ZxvaNN3/RtkBSAY6tL6OL3vzVuaHlx+SagY9QSEZMyjEu9xTF1dXLi8dZryY6f9b7tDs6Eae11ehRkb7bIkrz742eOeGoHFMFYveuJAyVmCc8c/344I63k0xhrlzhcmF47Mln7ulZbYqSs/8HT2UGtaVYGniahcJlCav6Wgw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733939430; c=relaxed/simple; bh=AZ+JyDm1s6BjQA0Ft/3tIw2C/SX35PYysRFWjGYUPjE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ROB7fNtBjAW8/Yq77Ku0MkFMStRLbTYnYhdIjLjHuShiLQivPBsf6ym3lcWEixVo1eTtVJF4iF58iVt0HaShMSMYLIoGHyGgEa2/8cJiFYayaPYs+aCVSNHS/zNKL3y2YhzgnAdN5XA/I8tSrCp7SiFWuK+HI4Rfihs+dr3x2nc= 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=EwLsDtE/; 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="EwLsDtE/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733939418; bh=AZ+JyDm1s6BjQA0Ft/3tIw2C/SX35PYysRFWjGYUPjE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=EwLsDtE/QHYr4T4bLQKNW92+7YwDReXtNmbSbgEC4MEHZ7OJN2DydMRg8aotw8lQM pONVt2OL2g3cLDOItoKy0OrnGGTpOfIlSOmYplExs5mNXx6kHSM2oxsj4TobwRs9la PcEsdElP9Vm0mk02zjHwEXgOZaxgJCZr/JfhVXY8= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 11 Dec 2024 18:50:17 +0100 Subject: [PATCH 02/12] w1: ds2406: 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: <20241211-sysfs-const-bin_attr-w1-v1-2-c4befd2aa7cc@weissschuh.net> References: <20241211-sysfs-const-bin_attr-w1-v1-0-c4befd2aa7cc@weissschuh.net> In-Reply-To: <20241211-sysfs-const-bin_attr-w1-v1-0-c4befd2aa7cc@weissschuh.net> To: Krzysztof Kozlowski 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=1733939417; l=1845; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=AZ+JyDm1s6BjQA0Ft/3tIw2C/SX35PYysRFWjGYUPjE=; b=FBBPLi0Ta1lh8DsAZXAfBELOyn9AVRKt3qqttbkDmz8oaiQkcBszi8VWLXL0b/XHWdPOEC7Me xmVv0iuNf03DcPcEU5ayv+VxVU/ZJdmIh23bjcgEz5jvleR9Ugno89c 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/w1/slaves/w1_ds2406.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/w1/slaves/w1_ds2406.c b/drivers/w1/slaves/w1_ds2406.c index 2f5926859b8b3300c31be3f1d59e570984036109..1cae9b243ff87f0013e55c7aa51= cd1798741e9ca 100644 --- a/drivers/w1/slaves/w1_ds2406.c +++ b/drivers/w1/slaves/w1_ds2406.c @@ -24,7 +24,7 @@ =20 static ssize_t w1_f12_read_state( 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) { u8 w1_buf[6] =3D {W1_F12_FUNC_READ_STATUS, 7, 0, 0, 0, 0}; @@ -61,7 +61,7 @@ static ssize_t w1_f12_read_state( =20 static ssize_t w1_f12_write_output( 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 w1_slave *sl =3D kobj_to_w1_slave(kobj); @@ -95,14 +95,14 @@ static ssize_t w1_f12_write_output( } =20 #define NB_SYSFS_BIN_FILES 2 -static struct bin_attribute w1_f12_sysfs_bin_files[NB_SYSFS_BIN_FILES] =3D= { +static const struct bin_attribute w1_f12_sysfs_bin_files[NB_SYSFS_BIN_FILE= S] =3D { { .attr =3D { .name =3D "state", .mode =3D 0444, }, .size =3D 1, - .read =3D w1_f12_read_state, + .read_new =3D w1_f12_read_state, }, { .attr =3D { @@ -110,7 +110,7 @@ static struct bin_attribute w1_f12_sysfs_bin_files[NB_S= YSFS_BIN_FILES] =3D { .mode =3D 0664, }, .size =3D 1, - .write =3D w1_f12_write_output, + .write_new =3D w1_f12_write_output, } }; =20 --=20 2.47.1 From nobody Sun Dec 14 13:49:28 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 BD7692040AD for ; Wed, 11 Dec 2024 17:50:31 +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=1733939433; cv=none; b=nw9jQc/q2J37KbZTinmkTyl1+v94mskUCRMz/yk1DgxLP1jGdP0Drq5D9gh05KMHrXxKajDYUqDMkr7fLBqRfsW+JrSTn/kBnliraQAyHImF4ft/G/Sl1qEqf1a0vtfMeYK2+Jb82zPky6grsayU8QBILEyzQ20dIFqF3ZZD9Qk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733939433; c=relaxed/simple; bh=J3vCtI5hdQabQGG0Jx/gVuyxcXRIrep+wGD5E3ZqU1s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=n5fMz+lQnXRp8/fvqdTE6s8wpy+lkANPVT9at6wY+ORsmD5I+SkUDLsqKH47Xgtd36q34rLURGth7sFfie3Bw2dHsns9+s7WYFcfBmW93AA2NZDqKGIV25l71eLBa9FFsZZnSvjMTVU8pTGmawM20Zga5sAEp6MOe8ZeJ6+TkTU= 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=RmF+FqYx; 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="RmF+FqYx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733939418; bh=J3vCtI5hdQabQGG0Jx/gVuyxcXRIrep+wGD5E3ZqU1s=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=RmF+FqYxo7LxC9NMrjiM8Rn3BGr+hqsVDoyNSxxfijLIXRJHZ8YcFwpXR//LiE3lD 92UjZiQNCncaIX/oc8xJmISUKRr3Ms5Kda9mNWjKRxuUlr0zebV+bKlsiXOWCE92NI sXKLP84Qej8RtKynGbhu6kypPuoVsbxrrFNt6D0M= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 11 Dec 2024 18:50:18 +0100 Subject: [PATCH 03/12] w1: ds2408: 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: <20241211-sysfs-const-bin_attr-w1-v1-3-c4befd2aa7cc@weissschuh.net> References: <20241211-sysfs-const-bin_attr-w1-v1-0-c4befd2aa7cc@weissschuh.net> In-Reply-To: <20241211-sysfs-const-bin_attr-w1-v1-0-c4befd2aa7cc@weissschuh.net> To: Krzysztof Kozlowski 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=1733939417; l=5344; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=J3vCtI5hdQabQGG0Jx/gVuyxcXRIrep+wGD5E3ZqU1s=; b=duuUEp6q1SdVl5y569ZOAVnjuJD/GJmSo7LHP0DvAd72XHbSsxV44g8smPAaJ/sY/GuC5yHPE apa8PmGd2lRBBGSGbQVSvfhkIpm3yQ8ubW7+6bt1kaYwKL3YgIsrLNo 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/w1/slaves/w1_ds2408.c | 42 +++++++++++++++++++++------------------= --- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/w1/slaves/w1_ds2408.c b/drivers/w1/slaves/w1_ds2408.c index 56f822a1dfdbed46ccc7db136255a1d021e6189a..beccd2912d2aeb9a5f83cabba19= c32946778a790 100644 --- a/drivers/w1/slaves/w1_ds2408.c +++ b/drivers/w1/slaves/w1_ds2408.c @@ -65,8 +65,8 @@ static int _read_reg(struct w1_slave *sl, u8 address, uns= igned char *buf) } =20 static ssize_t state_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, loff_t off, - size_t count) + const struct bin_attribute *bin_attr, char *buf, + loff_t off, size_t count) { dev_dbg(&kobj_to_w1_slave(kobj)->dev, "Reading %s kobj: %p, off: %0#10x, count: %zu, buff addr: %p", @@ -77,7 +77,7 @@ static ssize_t state_read(struct file *filp, struct kobje= ct *kobj, } =20 static ssize_t output_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { dev_dbg(&kobj_to_w1_slave(kobj)->dev, @@ -90,7 +90,7 @@ static ssize_t output_read(struct file *filp, struct kobj= ect *kobj, } =20 static ssize_t activity_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { dev_dbg(&kobj_to_w1_slave(kobj)->dev, @@ -103,8 +103,8 @@ static ssize_t activity_read(struct file *filp, struct = kobject *kobj, } =20 static ssize_t cond_search_mask_read(struct file *filp, struct kobject *ko= bj, - struct bin_attribute *bin_attr, char *buf, - loff_t off, size_t count) + const struct bin_attribute *bin_attr, + char *buf, loff_t off, size_t count) { dev_dbg(&kobj_to_w1_slave(kobj)->dev, "Reading %s kobj: %p, off: %0#10x, count: %zu, buff addr: %p", @@ -117,7 +117,7 @@ static ssize_t cond_search_mask_read(struct file *filp,= struct kobject *kobj, =20 static ssize_t cond_search_polarity_read(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) { if (count !=3D 1 || off !=3D 0) @@ -127,8 +127,8 @@ static ssize_t cond_search_polarity_read(struct file *f= ilp, } =20 static ssize_t status_control_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, - loff_t off, size_t count) + const struct bin_attribute *bin_attr, + char *buf, loff_t off, size_t count) { if (count !=3D 1 || off !=3D 0) return -EFAULT; @@ -160,7 +160,7 @@ static bool optional_read_back_valid(struct w1_slave *s= l, u8 expected) #endif =20 static ssize_t output_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { struct w1_slave *sl =3D kobj_to_w1_slave(kobj); @@ -210,7 +210,7 @@ static ssize_t output_write(struct file *filp, struct k= object *kobj, * Writing to the activity file resets the activity latches. */ static ssize_t activity_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { struct w1_slave *sl =3D kobj_to_w1_slave(kobj); @@ -240,8 +240,8 @@ static ssize_t activity_write(struct file *filp, struct= kobject *kobj, } =20 static ssize_t status_control_write(struct file *filp, struct kobject *kob= j, - struct bin_attribute *bin_attr, char *buf, - loff_t off, size_t count) + const struct bin_attribute *bin_attr, + char *buf, loff_t off, size_t count) { struct w1_slave *sl =3D kobj_to_w1_slave(kobj); u8 w1_buf[4]; @@ -310,14 +310,14 @@ static int w1_f29_disable_test_mode(struct w1_slave *= sl) return res; } =20 -static BIN_ATTR_RO(state, 1); -static BIN_ATTR_RW(output, 1); -static BIN_ATTR_RW(activity, 1); -static BIN_ATTR_RO(cond_search_mask, 1); -static BIN_ATTR_RO(cond_search_polarity, 1); -static BIN_ATTR_RW(status_control, 1); +static const BIN_ATTR_RO(state, 1); +static const BIN_ATTR_RW(output, 1); +static const BIN_ATTR_RW(activity, 1); +static const BIN_ATTR_RO(cond_search_mask, 1); +static const BIN_ATTR_RO(cond_search_polarity, 1); +static const BIN_ATTR_RW(status_control, 1); =20 -static struct bin_attribute *w1_f29_bin_attrs[] =3D { +static const struct bin_attribute *const w1_f29_bin_attrs[] =3D { &bin_attr_state, &bin_attr_output, &bin_attr_activity, @@ -328,7 +328,7 @@ static struct bin_attribute *w1_f29_bin_attrs[] =3D { }; =20 static const struct attribute_group w1_f29_group =3D { - .bin_attrs =3D w1_f29_bin_attrs, + .bin_attrs_new =3D w1_f29_bin_attrs, }; =20 static const struct attribute_group *w1_f29_groups[] =3D { --=20 2.47.1 From nobody Sun Dec 14 13:49:28 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 CC6D11FF1DE for ; Wed, 11 Dec 2024 17:50:25 +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=1733939430; cv=none; b=urrmZv+49L9nUDbFOI8joq2o4/y8As5E03mmc3JKMQj3baaFs5UuzIs5PX+e2BEKKbhDXirwks6XWijLR9gRduS7mLHOTDlacudu9repLNtXyFNCxnu/6gvcsX4yne85MT+KjFHnwC6VqPYpnun1oUSGJLMBl9mJ48cbbVY2sWE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733939430; c=relaxed/simple; bh=hNHDMYdl/asRQqaa03vfbr39VEHOA8MutLP7yYvBd8A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hkelLLQHJ5Uj2fC5YRDk7FirhQ1t7yypmoBRPmMllsoa7U5nXEgeWslcP0qC0LjASPekm0VT8xmBgbciolhiIaQnb1FylJ7ZsKI7pyqsZ5ZbCrnvKp2eaLslcOFLeZVa2aLlVNdiL+iVjXGcfjtXJTSkd3DMe3xulgSRmMxURAg= 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=WcNevTqg; 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="WcNevTqg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733939418; bh=hNHDMYdl/asRQqaa03vfbr39VEHOA8MutLP7yYvBd8A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=WcNevTqgfiMJvxCyqwoHugta35qvF4GP+AejVy927WDTLQhoKiV8Ao6GB6wztC6ya qgKiRJdo/zzDRD3Ak9PtaJ2KWHFwqF/EE3mj+fPfjpWb1zVqvswIZxE1vKap2Y6n/m LuUi6o3WpSkz54VnPrNz92yOEFoMUJryLCvsKvW8= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 11 Dec 2024 18:50:19 +0100 Subject: [PATCH 04/12] w1: ds2413: 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: <20241211-sysfs-const-bin_attr-w1-v1-4-c4befd2aa7cc@weissschuh.net> References: <20241211-sysfs-const-bin_attr-w1-v1-0-c4befd2aa7cc@weissschuh.net> In-Reply-To: <20241211-sysfs-const-bin_attr-w1-v1-0-c4befd2aa7cc@weissschuh.net> To: Krzysztof Kozlowski 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=1733939418; l=2094; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=hNHDMYdl/asRQqaa03vfbr39VEHOA8MutLP7yYvBd8A=; b=+ad/t2rZETTSaJhQQwaQMvF9R4dGdufmoIjV3KDym/QyHeh4YjQJJbhgVKHgzm+D0xjXhqkvK 6Nfda8Z+FMtC+Qw4EId+p7/l0D1PvctXCi8Z3TMbiu0biK8HS/0+pje 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/w1/slaves/w1_ds2413.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/w1/slaves/w1_ds2413.c b/drivers/w1/slaves/w1_ds2413.c index 7390098064679e2f751814bd5bcd7fa3f362808d..5fa46017ca7cd8ae8ff657adaa9= ed0e83f5d0e8b 100644 --- a/drivers/w1/slaves/w1_ds2413.c +++ b/drivers/w1/slaves/w1_ds2413.c @@ -25,8 +25,8 @@ #define W1_F3A_INVALID_PIO_STATE 0xFF =20 static ssize_t state_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, loff_t off, - size_t count) + const struct bin_attribute *bin_attr, char *buf, + loff_t off, size_t count) { struct w1_slave *sl =3D kobj_to_w1_slave(kobj); unsigned int retries =3D W1_F3A_RETRIES; @@ -78,10 +78,10 @@ static ssize_t state_read(struct file *filp, struct kob= ject *kobj, return bytes_read; } =20 -static BIN_ATTR_RO(state, 1); +static const BIN_ATTR_RO(state, 1); =20 static ssize_t output_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { struct w1_slave *sl =3D kobj_to_w1_slave(kobj); @@ -128,16 +128,16 @@ static ssize_t output_write(struct file *filp, struct= kobject *kobj, return bytes_written; } =20 -static BIN_ATTR(output, 0664, NULL, output_write, 1); +static const BIN_ATTR(output, 0664, NULL, output_write, 1); =20 -static struct bin_attribute *w1_f3a_bin_attrs[] =3D { +static const struct bin_attribute *const w1_f3a_bin_attrs[] =3D { &bin_attr_state, &bin_attr_output, NULL, }; =20 static const struct attribute_group w1_f3a_group =3D { - .bin_attrs =3D w1_f3a_bin_attrs, + .bin_attrs_new =3D w1_f3a_bin_attrs, }; =20 static const struct attribute_group *w1_f3a_groups[] =3D { --=20 2.47.1 From nobody Sun Dec 14 13:49:28 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 CC6661FF1D1 for ; Wed, 11 Dec 2024 17:50:26 +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=1733939429; cv=none; b=r8jf7LWorvXdlnoR6UlrOdwG/Wi2Jh7v3d/gOokVGghgL7LG774liv5T978qGYzkAiExRI0ExftrLuLlpCeAd9lyktjxpyf2Y9/h6GW2B9GLMEexv1P5synaNgQI7elGqHZmqkFqKSpMc/5G91HPJaY7wFQFT3uR7AqR6cDrvw0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733939429; c=relaxed/simple; bh=9ocxmATh3LJZkTpVvdOx9dEWaYWzc6nNHhkg7FFPmm0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=j/fgo/X1DJvaoUCAzbqiE3qYJmUpw8JjMzYUzW/+vnJ8sb7YbaYKKhZJ0xl1dnTRAaQcu7BgWXJdDCp7Lfaa80shUkYCvc/6r0tuhj4miWHpN9QBxSiMZzd9cIve25eOBhTesnY37MPm9DkYLFoZHANGdJCm32oQh5fJbhPMCJY= 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=Khw3oY59; 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="Khw3oY59" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733939418; bh=9ocxmATh3LJZkTpVvdOx9dEWaYWzc6nNHhkg7FFPmm0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Khw3oY59rR3cfpxW0Mb1881sGnq6QKAvEzOgpQ0QcriyAVihNZbclum6m8OaHABSW K12Ij/WbuCwxSi4Wl9u6Ue2dVzur8hx88ETqcHQ5TEef5VA+jMLx7QoExBTZcsjhjx W8HTBKE04CVTTbkVUzYXnL6lu8Lk58+XMKx0vbw4= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 11 Dec 2024 18:50:20 +0100 Subject: [PATCH 05/12] w1: ds2430: 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: <20241211-sysfs-const-bin_attr-w1-v1-5-c4befd2aa7cc@weissschuh.net> References: <20241211-sysfs-const-bin_attr-w1-v1-0-c4befd2aa7cc@weissschuh.net> In-Reply-To: <20241211-sysfs-const-bin_attr-w1-v1-0-c4befd2aa7cc@weissschuh.net> To: Krzysztof Kozlowski 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=1733939418; l=1931; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=9ocxmATh3LJZkTpVvdOx9dEWaYWzc6nNHhkg7FFPmm0=; b=pGWU/ox6BFZOX8HRGHdHVC5bYq3QQ8hfjtMG2lcd7fO7ETqpAo8HamRGXZtsD3Dmyohfz+fq/ Pot18GhBOgwBETpdDIxl52gY+TYyk0dM8Na1whSTSwORvfHmYg2uOZT 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/w1/slaves/w1_ds2430.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/w1/slaves/w1_ds2430.c b/drivers/w1/slaves/w1_ds2430.c index 0ea7d779d17aecf8cbdd19320a6df6070ed9d507..ff56e2e68e583b3bb4df82c119e= 9325271342595 100644 --- a/drivers/w1/slaves/w1_ds2430.c +++ b/drivers/w1/slaves/w1_ds2430.c @@ -95,7 +95,7 @@ static int w1_f14_readblock(struct w1_slave *sl, int off,= int count, char *buf) } =20 static ssize_t eeprom_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { struct w1_slave *sl =3D kobj_to_w1_slave(kobj); @@ -202,7 +202,7 @@ static int w1_f14_write(struct w1_slave *sl, int addr, = int len, const u8 *data) } =20 static ssize_t eeprom_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { struct w1_slave *sl =3D kobj_to_w1_slave(kobj); @@ -263,15 +263,15 @@ static ssize_t eeprom_write(struct file *filp, struct= kobject *kobj, return count; } =20 -static BIN_ATTR_RW(eeprom, W1_F14_EEPROM_SIZE); +static const BIN_ATTR_RW(eeprom, W1_F14_EEPROM_SIZE); =20 -static struct bin_attribute *w1_f14_bin_attrs[] =3D { +static const struct bin_attribute *const w1_f14_bin_attrs[] =3D { &bin_attr_eeprom, NULL, }; =20 static const struct attribute_group w1_f14_group =3D { - .bin_attrs =3D w1_f14_bin_attrs, + .bin_attrs_new =3D w1_f14_bin_attrs, }; =20 static const struct attribute_group *w1_f14_groups[] =3D { --=20 2.47.1 From nobody Sun Dec 14 13:49:28 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 BBDE920126B for ; Wed, 11 Dec 2024 17:50:30 +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=1733939432; cv=none; b=DZAkMiODGjrIjbi8xtSCjDL4Xwd5ou2vEkdH24Z8fm+E2lGeL/1YDNOBeDQVyIXbeiNrAZiFU3LbR4PkKVGbpqWf4PSXU46cQSjmu47Sb5wA8QREd3ZKTx8KURpmYnT55VX5Ri9YwNjqlaOLZZmpT48X4Hd4z/JdrEF5iWXyH4c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733939432; c=relaxed/simple; bh=K28ML1hqqA6gwMqXnOGpt/Gj5CvGgPCGHs5mNLnIE7I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=m9wbxLin2vwTovd2TeXXXbe/15CITPrY47R/+YrfGZ/wOPo1AFheVpt6XiURwL23BH+X7S9dtanBJE2PMfU6RkMNhjRO5RLOflRnHDNEgrud996GU6cZGllU/ugfoM5fPKI0iGQHUy4UYOLniDw/9liCD9LWTZ7/Sl+F8H/pSrg= 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=OLgEH0Ap; 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="OLgEH0Ap" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733939418; bh=K28ML1hqqA6gwMqXnOGpt/Gj5CvGgPCGHs5mNLnIE7I=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=OLgEH0ApCOoHJN6tSOdkSfgmgvexJBQRpkBSkKX8Wdiu3D9C99jnCgHdG1fPVHSjU ddXbdzfbhmrnkOFe05NKxAKgEh4UqDEQfNlIWYvbyPJzhz7P9PAwzzaudsikQlYCcS ckUIS0drzwSbdu8V7xOUx0MUHKBvKx8NJX94qPAM= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 11 Dec 2024 18:50:21 +0100 Subject: [PATCH 06/12] w1: ds2431: 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: <20241211-sysfs-const-bin_attr-w1-v1-6-c4befd2aa7cc@weissschuh.net> References: <20241211-sysfs-const-bin_attr-w1-v1-0-c4befd2aa7cc@weissschuh.net> In-Reply-To: <20241211-sysfs-const-bin_attr-w1-v1-0-c4befd2aa7cc@weissschuh.net> To: Krzysztof Kozlowski 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=1733939418; l=1931; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=K28ML1hqqA6gwMqXnOGpt/Gj5CvGgPCGHs5mNLnIE7I=; b=48dv9trO7Sad5mhBNvPtmHB5DfJMY+PDMRA/oU+UvdsXsBekJNSYdU7AZeJWpQrgRa2xdwrKN ILu1gTMaP/cCdcaZhcO8DSvVndqKItCxOIByQtsxi/Kbm8NcEAPJ6vK 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/w1/slaves/w1_ds2431.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/w1/slaves/w1_ds2431.c b/drivers/w1/slaves/w1_ds2431.c index 6856b1c29e179afe072ff06b94b3ba86759c7fcc..27b390fb59da11b610e1d126347= ddba46a2f4f29 100644 --- a/drivers/w1/slaves/w1_ds2431.c +++ b/drivers/w1/slaves/w1_ds2431.c @@ -95,7 +95,7 @@ static int w1_f2d_readblock(struct w1_slave *sl, int off,= int count, char *buf) } =20 static ssize_t eeprom_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { struct w1_slave *sl =3D kobj_to_w1_slave(kobj); @@ -201,7 +201,7 @@ static int w1_f2d_write(struct w1_slave *sl, int addr, = int len, const u8 *data) } =20 static ssize_t eeprom_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { struct w1_slave *sl =3D kobj_to_w1_slave(kobj); @@ -262,15 +262,15 @@ static ssize_t eeprom_write(struct file *filp, struct= kobject *kobj, return count; } =20 -static BIN_ATTR_RW(eeprom, W1_F2D_EEPROM_SIZE); +static const BIN_ATTR_RW(eeprom, W1_F2D_EEPROM_SIZE); =20 -static struct bin_attribute *w1_f2d_bin_attrs[] =3D { +static const struct bin_attribute *const w1_f2d_bin_attrs[] =3D { &bin_attr_eeprom, NULL, }; =20 static const struct attribute_group w1_f2d_group =3D { - .bin_attrs =3D w1_f2d_bin_attrs, + .bin_attrs_new =3D w1_f2d_bin_attrs, }; =20 static const struct attribute_group *w1_f2d_groups[] =3D { --=20 2.47.1 From nobody Sun Dec 14 13:49:28 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 72236203719 for ; Wed, 11 Dec 2024 17:50:31 +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=1733939433; cv=none; b=pE4WNk6CP6tTWNpgVsJozlu+dwnFtlkxHSMUbx8S13alNew4cnCXzjbBGqKIx034QFvydLbB7CWNmX16RqL07n15gX7nzB5SYxQnySKbXoThHv/yAgcxFHLHMk/QbEbGDARTUxP4WKgfXco/re/HrYawkQmstb0CD2kQzuH7muY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733939433; c=relaxed/simple; bh=Ojs3B544p0rHS9P9MqxyyOJrV4LPK6krTWQPqdCRmC0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lzYjWq3fEdTQWZDT2cmweGtg8KIER0Mwv5TCHzOtLHRtp2vTekdb6U53iTlMr9Pkud8f5qO+WEKonBTGibvRH4b/cEO4yKmytvhEWYwN9KD+1HdgG1yowwaO2cxt+m1gm2Gft/eR+TuqV2cn1lr4kblxrEdeccRDt3v5R3WPaOQ= 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=CgP5BP/k; 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="CgP5BP/k" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733939418; bh=Ojs3B544p0rHS9P9MqxyyOJrV4LPK6krTWQPqdCRmC0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=CgP5BP/kY4Nhj3oPBLqFrQDNM3SvgfnCZYGNsP+jiljF7fksXXd8Eo8RRCZgpnzQL LTvKSG+oOqKbO0P8o17rSeQiZHyzoCvWUZ7FhxDvG6BvSa8ywnePpE3X08WRnEwICa ZPEhGUVW1MEV9yrfwK/4lMPlS+8vbdn++SjXxDjw= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 11 Dec 2024 18:50:22 +0100 Subject: [PATCH 07/12] w1: ds2433: 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: <20241211-sysfs-const-bin_attr-w1-v1-7-c4befd2aa7cc@weissschuh.net> References: <20241211-sysfs-const-bin_attr-w1-v1-0-c4befd2aa7cc@weissschuh.net> In-Reply-To: <20241211-sysfs-const-bin_attr-w1-v1-0-c4befd2aa7cc@weissschuh.net> To: Krzysztof Kozlowski 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=1733939418; l=2998; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=Ojs3B544p0rHS9P9MqxyyOJrV4LPK6krTWQPqdCRmC0=; b=aT7eEsAwH/ltca6ri55VWjgudfeyNs4yPCXszWBJjFx9EVlf1jRTmvtVmsvv6UqQbY35gVoaQ Q+a6w8tEI1CDm03rMT/CCZ5ejMQt+q41ebFCGz1i6gELL1oQcisAweg 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/w1/slaves/w1_ds2433.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/w1/slaves/w1_ds2433.c b/drivers/w1/slaves/w1_ds2433.c index 250b7f7ec429e92a6146452a20d591644af4e083..22331d840ec18ae5fa6dfe7bd34= 37d8bb47057ad 100644 --- a/drivers/w1/slaves/w1_ds2433.c +++ b/drivers/w1/slaves/w1_ds2433.c @@ -110,7 +110,7 @@ static int w1_f23_refresh_block(struct w1_slave *sl, st= ruct w1_f23_data *data, #endif /* CONFIG_W1_SLAVE_DS2433_CRC */ =20 static ssize_t eeprom_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { struct w1_slave *sl =3D kobj_to_w1_slave(kobj); @@ -224,7 +224,7 @@ static int w1_f23_write(struct w1_slave *sl, int addr, = int len, const u8 *data) } =20 static ssize_t eeprom_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { struct w1_slave *sl =3D kobj_to_w1_slave(kobj); @@ -274,27 +274,27 @@ static ssize_t eeprom_write(struct file *filp, struct= kobject *kobj, return count; } =20 -static struct bin_attribute bin_attr_f23_eeprom =3D { +static const struct bin_attribute bin_attr_f23_eeprom =3D { .attr =3D { .name =3D "eeprom", .mode =3D 0644 }, - .read =3D eeprom_read, - .write =3D eeprom_write, + .read_new =3D eeprom_read, + .write_new =3D eeprom_write, .size =3D W1_EEPROM_DS2433_SIZE, }; =20 -static struct bin_attribute bin_attr_f43_eeprom =3D { +static const struct bin_attribute bin_attr_f43_eeprom =3D { .attr =3D { .name =3D "eeprom", .mode =3D 0644 }, - .read =3D eeprom_read, - .write =3D eeprom_write, + .read_new =3D eeprom_read, + .write_new =3D eeprom_write, .size =3D W1_EEPROM_DS28EC20_SIZE, }; =20 -static struct bin_attribute *w1_f23_bin_attributes[] =3D { +static const struct bin_attribute *const w1_f23_bin_attributes[] =3D { &bin_attr_f23_eeprom, NULL, }; =20 static const struct attribute_group w1_f23_group =3D { - .bin_attrs =3D w1_f23_bin_attributes, + .bin_attrs_new =3D w1_f23_bin_attributes, }; =20 static const struct attribute_group *w1_f23_groups[] =3D { @@ -302,13 +302,13 @@ static const struct attribute_group *w1_f23_groups[] = =3D { NULL, }; =20 -static struct bin_attribute *w1_f43_bin_attributes[] =3D { +static const struct bin_attribute *const w1_f43_bin_attributes[] =3D { &bin_attr_f43_eeprom, NULL, }; =20 static const struct attribute_group w1_f43_group =3D { - .bin_attrs =3D w1_f43_bin_attributes, + .bin_attrs_new =3D w1_f43_bin_attributes, }; =20 static const struct attribute_group *w1_f43_groups[] =3D { --=20 2.47.1 From nobody Sun Dec 14 13:49:28 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 BBD8D201267 for ; Wed, 11 Dec 2024 17:50:30 +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=1733939432; cv=none; b=PgHXlmashBtsM0+fZxH4xzNkf2Gh4LmEblhis0AtcFNwt/M/2ZRPZ1i5y8GMLxsz0Grsl6RKGc+i5RNhINllFt2/qJ862ogm1hPfIIy1w+GMB9nYCRsmV1azS7eH2JzDSwXK3JS9FlbzGg3aGy8leL7lbNtZSMkUUL5SYdTzJfE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733939432; c=relaxed/simple; bh=ARO5UZ4nujLsozplk8hxJJBHhcGp9DQWJ4aefMn2kr4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WNqMQ+Y0QLuT0lYfy9kGCQqgHtJuInO+RCCf1YL1sG4yjy2Sa8PWSfGV18G3gh7qXOjrC6uEbtLWZ1uvLxROeRlfdCrMOKt3jNdWFjUnP+U+aBfTyz/iN4+irrT11CxThV4QlN/7aUbvvNAczuyP9xqCr5zmvKTTzVMA9zDZpog= 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=XDCsGxJS; 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="XDCsGxJS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733939418; bh=ARO5UZ4nujLsozplk8hxJJBHhcGp9DQWJ4aefMn2kr4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=XDCsGxJSpREFR8Mw+k2E7iZRmfoYEWENS7s9+l4JveCiOsOnMwE/GeqqcjhaFT2Wi lsbdRnD9d3QD0RmTDUUes0sEQqvXVS0GFZp67VJlBsv3mXw0hijbBnasnLt7z6MWB/ wg3syymVGIEEOTuedH8Ce0hjasPVfi4kkCmg4guc= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 11 Dec 2024 18:50:23 +0100 Subject: [PATCH 08/12] w1: ds2438: 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: <20241211-sysfs-const-bin_attr-w1-v1-8-c4befd2aa7cc@weissschuh.net> References: <20241211-sysfs-const-bin_attr-w1-v1-0-c4befd2aa7cc@weissschuh.net> In-Reply-To: <20241211-sysfs-const-bin_attr-w1-v1-0-c4befd2aa7cc@weissschuh.net> To: Krzysztof Kozlowski 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=1733939418; l=4754; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=ARO5UZ4nujLsozplk8hxJJBHhcGp9DQWJ4aefMn2kr4=; b=aNAJnV+bcYDx4Xkjh1MLcVdNNQScwTus1HoZBOA6G5pNCWIDd1jgVZmTSocIKW0wWNrz+9Wr5 JqhOZnvn069Cl0RuXRFysWPDBS2JcAcetVKRWbftNWC52FaaRmibOG6 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/w1/slaves/w1_ds2438.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/w1/slaves/w1_ds2438.c b/drivers/w1/slaves/w1_ds2438.c index e008c27b3db9efaaba4e6965cc7c3ff032afe3cc..630a6db5045e8c2985cae6fef68= 4bb6f2081f95d 100644 --- a/drivers/w1/slaves/w1_ds2438.c +++ b/drivers/w1/slaves/w1_ds2438.c @@ -288,7 +288,7 @@ static int w1_ds2438_get_current(struct w1_slave *sl, i= nt16_t *voltage) } =20 static ssize_t iad_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { struct w1_slave *sl =3D kobj_to_w1_slave(kobj); @@ -310,7 +310,7 @@ static ssize_t iad_write(struct file *filp, struct kobj= ect *kobj, } =20 static ssize_t iad_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { struct w1_slave *sl =3D kobj_to_w1_slave(kobj); @@ -331,7 +331,7 @@ static ssize_t iad_read(struct file *filp, struct kobje= ct *kobj, } =20 static ssize_t page0_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { struct w1_slave *sl =3D kobj_to_w1_slave(kobj); @@ -361,7 +361,7 @@ static ssize_t page0_read(struct file *filp, struct kob= ject *kobj, } =20 static ssize_t page1_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { struct w1_slave *sl =3D kobj_to_w1_slave(kobj); @@ -391,7 +391,7 @@ static ssize_t page1_read(struct file *filp, struct kob= ject *kobj, } =20 static ssize_t offset_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { struct w1_slave *sl =3D kobj_to_w1_slave(kobj); @@ -410,7 +410,7 @@ static ssize_t offset_write(struct file *filp, struct k= object *kobj, } =20 static ssize_t temperature_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { struct w1_slave *sl =3D kobj_to_w1_slave(kobj); @@ -431,7 +431,7 @@ static ssize_t temperature_read(struct file *filp, stru= ct kobject *kobj, } =20 static ssize_t vad_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { struct w1_slave *sl =3D kobj_to_w1_slave(kobj); @@ -452,7 +452,7 @@ static ssize_t vad_read(struct file *filp, struct kobje= ct *kobj, } =20 static ssize_t vdd_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { struct w1_slave *sl =3D kobj_to_w1_slave(kobj); @@ -472,15 +472,15 @@ static ssize_t vdd_read(struct file *filp, struct kob= ject *kobj, return ret; } =20 -static BIN_ATTR_RW(iad, 0); -static BIN_ATTR_RO(page0, DS2438_PAGE_SIZE); -static BIN_ATTR_RO(page1, DS2438_PAGE_SIZE); -static BIN_ATTR_WO(offset, 2); -static BIN_ATTR_RO(temperature, 0/* real length varies */); -static BIN_ATTR_RO(vad, 0/* real length varies */); -static BIN_ATTR_RO(vdd, 0/* real length varies */); +static const BIN_ATTR_RW(iad, 0); +static const BIN_ATTR_RO(page0, DS2438_PAGE_SIZE); +static const BIN_ATTR_RO(page1, DS2438_PAGE_SIZE); +static const BIN_ATTR_WO(offset, 2); +static const BIN_ATTR_RO(temperature, 0/* real length varies */); +static const BIN_ATTR_RO(vad, 0/* real length varies */); +static const BIN_ATTR_RO(vdd, 0/* real length varies */); =20 -static struct bin_attribute *w1_ds2438_bin_attrs[] =3D { +static const struct bin_attribute *const w1_ds2438_bin_attrs[] =3D { &bin_attr_iad, &bin_attr_page0, &bin_attr_page1, @@ -492,7 +492,7 @@ static struct bin_attribute *w1_ds2438_bin_attrs[] =3D { }; =20 static const struct attribute_group w1_ds2438_group =3D { - .bin_attrs =3D w1_ds2438_bin_attrs, + .bin_attrs_new =3D w1_ds2438_bin_attrs, }; =20 static const struct attribute_group *w1_ds2438_groups[] =3D { --=20 2.47.1 From nobody Sun Dec 14 13:49:28 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 CC8B6204F61 for ; Wed, 11 Dec 2024 17:50:31 +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=1733939433; cv=none; b=FjIKPvvdldSv3v5D3Yhy9yqLdmyKPrd7Mfg1NHMoRLO3KjO48WfM6CSK3x3tZWjB1RFTOcmhv1w3NWy0dMqsb7NPOQdiXrkW3Eq1ULl0Rq+/DlxlPbxNbHsluZXcTYdOPXDKK+pFAK1GM56K8Qi8EpmDKFOHvzRG8C5U5ycCZXE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733939433; c=relaxed/simple; bh=frkUSQXMfgqlNH7WR6G8UTYRdIbi+CzS3x05VMGy3Vg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gPXwO79/7cQFO7uwTpQqIC4lREvsk+Om2cBTJbWldumcpxUsOziPH0IInPo3idNM9DJcaW71PYJO8F4DGkcoG5W1XlfpIR+Od4tokQOG6zMK7mx+im7Z/A3pdItP6tZdnn9F2rQGjli8t2g08zAfSnD4xpd/zkd7GfxS737c9lk= 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=iHxyygQq; 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="iHxyygQq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733939419; bh=frkUSQXMfgqlNH7WR6G8UTYRdIbi+CzS3x05VMGy3Vg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=iHxyygQqFbqmFGrtKKqBG0k22GU1CcmB/d71LnmkaQRGcXCvw1TMCa/hIGVl7XMYj txAbKKfHoP9lTfe3DrhSmtEN7JaSfYK3qw5eiD6GaeyC5hOUaSrvo0+I1/uQ8vq6re Ci6f28BjN2OAYftL1UyiHTYhZE2Z3vFRvGxeReX0= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 11 Dec 2024 18:50:24 +0100 Subject: [PATCH 09/12] w1: ds2780: 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: <20241211-sysfs-const-bin_attr-w1-v1-9-c4befd2aa7cc@weissschuh.net> References: <20241211-sysfs-const-bin_attr-w1-v1-0-c4befd2aa7cc@weissschuh.net> In-Reply-To: <20241211-sysfs-const-bin_attr-w1-v1-0-c4befd2aa7cc@weissschuh.net> To: Krzysztof Kozlowski 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=1733939418; l=1623; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=frkUSQXMfgqlNH7WR6G8UTYRdIbi+CzS3x05VMGy3Vg=; b=GLy4SN79dPswTLsvD2ZvWnfSsn87yzfAMxhYeLGJp58lhExeQ5tptf4O10ueb9dtmuPOD3JL5 GDKdalo18ekDQ9PpmrR7jfwKXiKfQm5R8rIYzt7IPchBURPHiEPxQsu 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/w1/slaves/w1_ds2780.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/w1/slaves/w1_ds2780.c b/drivers/w1/slaves/w1_ds2780.c index 3cde1bb1886b1acb1b37e471a2961f9ff0a2f11f..ba7beb7b01f98d631d61c448475= 40068ece4bdd6 100644 --- a/drivers/w1/slaves/w1_ds2780.c +++ b/drivers/w1/slaves/w1_ds2780.c @@ -87,7 +87,7 @@ int w1_ds2780_eeprom_cmd(struct device *dev, int addr, in= t cmd) EXPORT_SYMBOL(w1_ds2780_eeprom_cmd); =20 static ssize_t w1_slave_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { struct device *dev =3D kobj_to_dev(kobj); @@ -95,15 +95,15 @@ static ssize_t w1_slave_read(struct file *filp, struct = kobject *kobj, return w1_ds2780_io(dev, buf, off, count, 0); } =20 -static BIN_ATTR_RO(w1_slave, DS2780_DATA_SIZE); +static const BIN_ATTR_RO(w1_slave, DS2780_DATA_SIZE); =20 -static struct bin_attribute *w1_ds2780_bin_attrs[] =3D { +static const struct bin_attribute *const w1_ds2780_bin_attrs[] =3D { &bin_attr_w1_slave, NULL, }; =20 static const struct attribute_group w1_ds2780_group =3D { - .bin_attrs =3D w1_ds2780_bin_attrs, + .bin_attrs_new =3D w1_ds2780_bin_attrs, }; =20 static const struct attribute_group *w1_ds2780_groups[] =3D { --=20 2.47.1 From nobody Sun Dec 14 13:49:28 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 721DC203717 for ; Wed, 11 Dec 2024 17:50:31 +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=1733939433; cv=none; b=RKgd7SkaWLI3g6LDPlC8EJKdukwTrlQu4MlpSo1sU9U3KitA07gRZwZdwAxAPecS/1jo6MBmTI8C+vtkN/a7DBfHyu7u2LFJdZYXgJjXLfVk8Np4MOP7vqAWXrGTNwxL1W6uTTbZu08+5vHb7a/STciw9m7Dj//Urgw1bzEy6Do= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733939433; c=relaxed/simple; bh=P6DBml8KrtQ/YAj969y7H9LijFtK4LKZTE4QTzRzjxE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dQr5A4V9jX7bk1vXyKpv7hHBfGckmCNFSAV02KGoh99zVMQRZO90CS4+5J4zUCB1dE2KGnCBdPD9OgM0EHXVuLNHRmAlas7/5RRqegb73aQHT9E3dcrCDQ8pXdFflDH/6vE84Y87GsNIrQ+9xRg9vO++p1MqBLAytBClHGd/46w= 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=Rs+ay3Hy; 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="Rs+ay3Hy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733939419; bh=P6DBml8KrtQ/YAj969y7H9LijFtK4LKZTE4QTzRzjxE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Rs+ay3HyBopAVXFA3dEhMgO+ooP5O+//cHoSuh3IrWcj/2xYezfVF6JbAo89v1ISn W9uVI26AuVZTeOSZ0EipDliu22HcwYCLFXLI57dOdSd4lucpeLiew8+kVyca0Inw1u aNDe/pP9KhPlMTvVUI44KHl4eXCAvItzWpYLjabc= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 11 Dec 2024 18:50:25 +0100 Subject: [PATCH 10/12] w1: ds2781: 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: <20241211-sysfs-const-bin_attr-w1-v1-10-c4befd2aa7cc@weissschuh.net> References: <20241211-sysfs-const-bin_attr-w1-v1-0-c4befd2aa7cc@weissschuh.net> In-Reply-To: <20241211-sysfs-const-bin_attr-w1-v1-0-c4befd2aa7cc@weissschuh.net> To: Krzysztof Kozlowski 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=1733939418; l=1623; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=P6DBml8KrtQ/YAj969y7H9LijFtK4LKZTE4QTzRzjxE=; b=pN3DzF9bRtBeUGejWHvMxGeZ95Sym1eamI8MK4C/ZwFLlgw85yLeVgGwcR0skihEoMelHCYpf 2dEDLOsbe/KD0OgK0DxRYGWHAV2SQBBS+jIK+B49SVMgsD/H95626WK 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/w1/slaves/w1_ds2781.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/w1/slaves/w1_ds2781.c b/drivers/w1/slaves/w1_ds2781.c index e418484b4a49e8474fbcdefac2d3599dcf9e2115..acd04ee96e81bd028e026711749= 649c59e35a141 100644 --- a/drivers/w1/slaves/w1_ds2781.c +++ b/drivers/w1/slaves/w1_ds2781.c @@ -84,7 +84,7 @@ int w1_ds2781_eeprom_cmd(struct device *dev, int addr, in= t cmd) EXPORT_SYMBOL(w1_ds2781_eeprom_cmd); =20 static ssize_t w1_slave_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { struct device *dev =3D kobj_to_dev(kobj); @@ -92,15 +92,15 @@ static ssize_t w1_slave_read(struct file *filp, struct = kobject *kobj, return w1_ds2781_io(dev, buf, off, count, 0); } =20 -static BIN_ATTR_RO(w1_slave, DS2781_DATA_SIZE); +static const BIN_ATTR_RO(w1_slave, DS2781_DATA_SIZE); =20 -static struct bin_attribute *w1_ds2781_bin_attrs[] =3D { +static const struct bin_attribute *const w1_ds2781_bin_attrs[] =3D { &bin_attr_w1_slave, NULL, }; =20 static const struct attribute_group w1_ds2781_group =3D { - .bin_attrs =3D w1_ds2781_bin_attrs, + .bin_attrs_new =3D w1_ds2781_bin_attrs, }; =20 static const struct attribute_group *w1_ds2781_groups[] =3D { --=20 2.47.1 From nobody Sun Dec 14 13:49:28 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 BD7D320468B for ; Wed, 11 Dec 2024 17:50:31 +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=1733939434; cv=none; b=KK2Mrw+s48aupWz9XNJh3/gzMKJSbWNlGFppHZ+aITIBy2ZgXg/13uA58K2NBcbDHFxHQLYlUvp394JANBdUkV8I3B4b8E0lhgqDKEUggQbmGCFBH4Rk28QpczpTexOfNcVMlXG5kQwz5LHjHjft2KGtdcOkAXftvGE6ejSQn7c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733939434; c=relaxed/simple; bh=2Ok+j45K8wKtGWNRe98OVgySAaImjbysWId+0805zSU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=l7mVJRHU5m/0WlLl0TlR7GpRzZua21mfM8mz8/7Y15rbfJnHq1QjG/EARMXrkPPrQFkD5natpVjOoRPXE05KDYl2RG5TMc+wn6CS9CQpk25vgV3X7+28DA2TfrCQDhRaB3uYP7b/EKOcG062vykqWWCn3d5Z/9k2wh2Oan+zW0Q= 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=o/n0myEd; 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="o/n0myEd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733939419; bh=2Ok+j45K8wKtGWNRe98OVgySAaImjbysWId+0805zSU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=o/n0myEdZCRslFbZjvwWSof1qJJLcJeRmLyO5NF3S4TOBH6opqfs2vwjzmnrNiZgl WW8zRVSKlaU2e3zzlBPtcsSBU7N/KZhT3gSFeZI6BytFMpIgGVCbyoiz/zWnYR0XXY 4fpR8m+PoQBkbxxF2Aq7wMBzp62AMQPzj+01e5X8= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 11 Dec 2024 18:50:26 +0100 Subject: [PATCH 11/12] w1: ds2805: 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: <20241211-sysfs-const-bin_attr-w1-v1-11-c4befd2aa7cc@weissschuh.net> References: <20241211-sysfs-const-bin_attr-w1-v1-0-c4befd2aa7cc@weissschuh.net> In-Reply-To: <20241211-sysfs-const-bin_attr-w1-v1-0-c4befd2aa7cc@weissschuh.net> To: Krzysztof Kozlowski 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=1733939418; l=1842; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=2Ok+j45K8wKtGWNRe98OVgySAaImjbysWId+0805zSU=; b=Pr9wejeUDNYqNNnEmI7g5w7SFdXh6PtHTu1+v6sE9xwht3tIWtRy8MapaMYGAAT8ZPK/x6wMT N7wMcy0TZDEApr+i8GDcgRMhGF+jQtGhKTDUCXfXHXcwBQ8HT4w2qFO 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/w1/slaves/w1_ds2805.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/w1/slaves/w1_ds2805.c b/drivers/w1/slaves/w1_ds2805.c index 4c1a2c51531779b2a10e136e25309171e697d89f..6ee895640d4ac781281e48ed01d= 9cb20cb71637c 100644 --- a/drivers/w1/slaves/w1_ds2805.c +++ b/drivers/w1/slaves/w1_ds2805.c @@ -92,7 +92,7 @@ static int w1_f0d_readblock(struct w1_slave *sl, int off,= int count, char *buf) } =20 static ssize_t w1_f0d_read_bin(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 w1_slave *sl =3D kobj_to_w1_slave(kobj); @@ -200,7 +200,7 @@ static int w1_f0d_write(struct w1_slave *sl, int addr, = int len, const u8 *data) } =20 static ssize_t w1_f0d_write_bin(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 w1_slave *sl =3D kobj_to_w1_slave(kobj); @@ -261,14 +261,14 @@ static ssize_t w1_f0d_write_bin(struct file *filp, st= ruct kobject *kobj, return count; } =20 -static struct bin_attribute w1_f0d_bin_attr =3D { +static const struct bin_attribute w1_f0d_bin_attr =3D { .attr =3D { .name =3D "eeprom", .mode =3D 0644, }, .size =3D W1_F0D_EEPROM_SIZE, - .read =3D w1_f0d_read_bin, - .write =3D w1_f0d_write_bin, + .read_new =3D w1_f0d_read_bin, + .write_new =3D w1_f0d_write_bin, }; =20 static int w1_f0d_add_slave(struct w1_slave *sl) --=20 2.47.1 From nobody Sun Dec 14 13:49:28 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 CC917204F6A for ; Wed, 11 Dec 2024 17:50:31 +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=1733939434; cv=none; b=dy9S0VVPjSmTR1gel/IwamfzFkcZPn0U7T/qTbW0QnVdlgtaLvHXTaZeif8kTPEPG/YEVmnkG8PSblS49/TuQ6pG2uhvKIsndrRblKvTDeWpn1ubyu/foXBtvP7BndcvQOV6cryJxjlraoDnS3lk3NWV4RcfuI3ZkR0ywWlbqpY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733939434; c=relaxed/simple; bh=KK19iir1m59O/VjJu95BHnHglib78OZ0Gp0fadyWNAk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=P6fDjvMTsSHOhnvtZBKJDYMaSyGJvqUObSo4zOT38v59fPu93PyQ2z8SA8z19OwcISj4WpsTQxE/gqeVVPI16/mwyLRP4gZos88oZcGALK02Epfhlr5VdneVmQ+VJFXpp4PvL+8ixFpQ5z3oO9V1l6OCiaJczYKNO0KsKqxHPD0= 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=uAQpHu4T; 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="uAQpHu4T" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733939419; bh=KK19iir1m59O/VjJu95BHnHglib78OZ0Gp0fadyWNAk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=uAQpHu4TYcM+7XgyKrLM/dAoSrGT/MUS/mz5tPPe/kAi7vEeMQFso6EWfyWXMPiU9 pLnjwZ+mIEt8G2j2+hPZcscdHus3ox+2ckFGXWZLYv+lxJ4IZ55e0Y1URumlrA1U1o 8Q/e/RwQjpESd1iegdC3pDRhJs252BtjAfeugF+0= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 11 Dec 2024 18:50:27 +0100 Subject: [PATCH 12/12] w1: ds28e04: 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: <20241211-sysfs-const-bin_attr-w1-v1-12-c4befd2aa7cc@weissschuh.net> References: <20241211-sysfs-const-bin_attr-w1-v1-0-c4befd2aa7cc@weissschuh.net> In-Reply-To: <20241211-sysfs-const-bin_attr-w1-v1-0-c4befd2aa7cc@weissschuh.net> To: Krzysztof Kozlowski 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=1733939418; l=2969; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=KK19iir1m59O/VjJu95BHnHglib78OZ0Gp0fadyWNAk=; b=xNZBL48ByI2FbIBtiklvPcqvgTduc7324TPOJvPIZWj170NpUEU8WQI2SL0QwkCLKo6/gU9/v WpZHl2gfnDDBcqcLERpUMFameVVzdKklB2G18Ejhs/vZ7GYU3DhHOwo 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/w1/slaves/w1_ds28e04.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/w1/slaves/w1_ds28e04.c b/drivers/w1/slaves/w1_ds28e04.c index 2854b8b9e93f798b93127a0eda926d5ce29baa0d..d99ffadbe29bb48a5c60239b4d6= f4cb0d7a5cb5d 100644 --- a/drivers/w1/slaves/w1_ds28e04.c +++ b/drivers/w1/slaves/w1_ds28e04.c @@ -112,7 +112,7 @@ static int w1_f1C_read(struct w1_slave *sl, int addr, i= nt len, char *data) } =20 static ssize_t eeprom_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { struct w1_slave *sl =3D kobj_to_w1_slave(kobj); @@ -223,7 +223,7 @@ static int w1_f1C_write(struct w1_slave *sl, int addr, = int len, const u8 *data) } =20 static ssize_t eeprom_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) =20 { @@ -276,10 +276,10 @@ static ssize_t eeprom_write(struct file *filp, struct= kobject *kobj, return count; } =20 -static BIN_ATTR_RW(eeprom, W1_EEPROM_SIZE); +static const BIN_ATTR_RW(eeprom, W1_EEPROM_SIZE); =20 static ssize_t pio_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, loff_t off, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) =20 { @@ -298,8 +298,8 @@ static ssize_t pio_read(struct file *filp, struct kobje= ct *kobj, } =20 static ssize_t pio_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, loff_t off, - size_t count) + const struct bin_attribute *bin_attr, char *buf, + loff_t off, size_t count) =20 { struct w1_slave *sl =3D kobj_to_w1_slave(kobj); @@ -337,7 +337,7 @@ static ssize_t pio_write(struct file *filp, struct kobj= ect *kobj, return count; } =20 -static BIN_ATTR_RW(pio, 1); +static const BIN_ATTR_RW(pio, 1); =20 static ssize_t crccheck_show(struct device *dev, struct device_attribute *= attr, char *buf) @@ -363,7 +363,7 @@ static struct attribute *w1_f1C_attrs[] =3D { NULL, }; =20 -static struct bin_attribute *w1_f1C_bin_attrs[] =3D { +static const struct bin_attribute *const w1_f1C_bin_attrs[] =3D { &bin_attr_eeprom, &bin_attr_pio, NULL, @@ -371,7 +371,7 @@ static struct bin_attribute *w1_f1C_bin_attrs[] =3D { =20 static const struct attribute_group w1_f1C_group =3D { .attrs =3D w1_f1C_attrs, - .bin_attrs =3D w1_f1C_bin_attrs, + .bin_attrs_new =3D w1_f1C_bin_attrs, }; =20 static const struct attribute_group *w1_f1C_groups[] =3D { --=20 2.47.1