From nobody Wed Dec 17 19:53:52 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 D0EF5203D50 for ; Mon, 16 Dec 2024 11:33:03 +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=1734348785; cv=none; b=gK00+BvbcWh/ejOlLlFF5n+5d2MsuUqEcVXbxw0O7F59JI9CUQW8B5hs2/cRU/bweJ7uzC2L3ikqeuahNetdLrUmyof9+9o8L3nFe92Yrf2FSXQxVedwSpA+IIKJwDSOflkJTivmuTB8VfM9ErIsJzgJzztEWGjzrmHeqsXahm4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734348785; c=relaxed/simple; bh=FtAXAyK33C589+S6JQ5FOb5ZXZI9TCjN1J5zeoHgJe4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=X27KDWhVeI5bxuNVagbOVJgE07dDX4sd5i2ALj5N3tVb/WPq9H7c+A/Sc85mAQNU1qb00q/lRAj6Kb3ZbuH2/jnLy7LYF0IO3qDUlKcusIp6BpJ8VKxOQkDPQJoITAkMe1AiynrJqxCkRZMFxT1go6ytf5y28L1NIBxnmpWNCM8= 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=uR6FKeW5; 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="uR6FKeW5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734348781; bh=FtAXAyK33C589+S6JQ5FOb5ZXZI9TCjN1J5zeoHgJe4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=uR6FKeW5WemX75/DpwkpBUUCpL65H1aFnpr0t8HgXiJqnknlY8LoYHlwqkPu4iutA yDMhKqcGpes9Bz7STcfERxVg2AToGTsDDCBiTxK/1uzZgXOVwFYfvhqjweerR2H+Vv iZggsiTn7pDhkO8gjcqFaC+ciRTgao0ZTCBAZGV4= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 16 Dec 2024 12:32:56 +0100 Subject: [PATCH 1/9] ocxl: 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-1-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=1409; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=FtAXAyK33C589+S6JQ5FOb5ZXZI9TCjN1J5zeoHgJe4=; b=7YG497eEqeHdVldUHhxXeVxJPMnzNYLDz/i1aXZ4WDfHJBu+adlcVWn9wpigL5EQ/xT7FRLsY jqdPY64QgfkBPUA/Qf/D0TksQxgf0I+vSdbUPsdYlKjMgagPVeSZ6st 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 Acked-by: Andrew Donnellan --- drivers/misc/ocxl/sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/misc/ocxl/sysfs.c b/drivers/misc/ocxl/sysfs.c index 07520d6e6dc55702696b8656440914c379e6e27a..e849641687a005fec5eb7a6b2e9= 6bc0e9d04dc05 100644 --- a/drivers/misc/ocxl/sysfs.c +++ b/drivers/misc/ocxl/sysfs.c @@ -94,7 +94,7 @@ static struct device_attribute afu_attrs[] =3D { }; =20 static ssize_t global_mmio_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 ocxl_afu *afu =3D to_afu(kobj_to_dev(kobj)); @@ -155,7 +155,7 @@ int ocxl_sysfs_register_afu(struct ocxl_file_info *info) info->attr_global_mmio.attr.name =3D "global_mmio_area"; info->attr_global_mmio.attr.mode =3D 0600; info->attr_global_mmio.size =3D info->afu->config.global_mmio_size; - info->attr_global_mmio.read =3D global_mmio_read; + info->attr_global_mmio.read_new =3D global_mmio_read; info->attr_global_mmio.mmap =3D global_mmio_mmap; rc =3D device_create_bin_file(&info->dev, &info->attr_global_mmio); if (rc) { --=20 2.47.1 From nobody Wed Dec 17 19:53:52 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 51FF2205ABE for ; Mon, 16 Dec 2024 11:33:07 +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=1734348789; cv=none; b=dsVCbAwGvdn8RpBvxOtj2nJqoY9LHuP4Fx/WfD5XICHo4OioQfUz5uqBx7ijQ83WDb0wRYOYFZYn9kDIcWtq0KRIoyqI/CMiLZ5JiPzjt1o7aMx1B94P74MvErUtY5DXwna9CRUIBwBvTXRj9mCdkqGWrXGSA6zlJQv6ERG7u0w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734348789; c=relaxed/simple; bh=YZVj6n6MUOQkXt6QAAL170xdLVYk+e61jPPq6fs3yDY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Qmv2vrN4hqYLEx7mhYVTu2pJsHySP0spcc7btOFi2cK4WTkSeP1/LHuewdzM+Own9YxT95okwzaAEHLTp7psgUu0rE0LDEz0vwnz7Mnj0u9uCXCS7J2ZdTRUnygAmyZjQyD6fF/y1lJU2HuvTt2tlNgbW+2u9t6xYP5nCgzhclY= 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=TIC7WH5F; 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="TIC7WH5F" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734348781; bh=YZVj6n6MUOQkXt6QAAL170xdLVYk+e61jPPq6fs3yDY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=TIC7WH5Fs7auSpnyx7AvYOMl5F9RiWBqyIEoEIz3GN1JNKyDGkvU+153FtDvWNHT3 Wgivpato4Er2WPrPKdIxaIT9urCsfOZ57wD1iC730eyKrUZsNzn03bbgSPUPiZmB4X 46ZSGOChSO6kSD539ppaY28qRuaFWxO1ZZxWDuNo= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 16 Dec 2024 12:32:57 +0100 Subject: [PATCH 2/9] cxl: 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-2-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=2071; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=YZVj6n6MUOQkXt6QAAL170xdLVYk+e61jPPq6fs3yDY=; b=dKNk6Ka86NjpVyOFYNLfo8D+1J/kscX1zKth6ShzAMoKs/hjMigT19zGTS2WtWemS12t34x+x XnZDPED1MGfDFY7A1fBBmrf6KXKrav90FMeUx1R6RrqaWJ0Yk6jMhAm 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 Acked-by: Andrew Donnellan --- drivers/misc/cxl/sysfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/misc/cxl/sysfs.c b/drivers/misc/cxl/sysfs.c index 409bd1c39663159a0d11c3ccba2aa5a8451baa34..b1fc6446bd4b7caa2f5c6e23e0a= ba5934caffd46 100644 --- a/drivers/misc/cxl/sysfs.c +++ b/drivers/misc/cxl/sysfs.c @@ -444,7 +444,7 @@ static ssize_t api_version_compatible_show(struct devic= e *device, } =20 static ssize_t afu_eb_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 cxl_afu *afu =3D to_cxl_afu(kobj_to_dev(kobj)); @@ -538,7 +538,7 @@ static ssize_t class_show(struct kobject *kobj, } =20 static ssize_t afu_read_config(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 afu_config_record *cr =3D to_cr(kobj); @@ -620,7 +620,7 @@ static struct afu_config_record *cxl_sysfs_afu_new_cr(s= truct cxl_afu *afu, int c cr->config_attr.attr.name =3D "config"; cr->config_attr.attr.mode =3D S_IRUSR; cr->config_attr.size =3D afu->crs_len; - cr->config_attr.read =3D afu_read_config; + cr->config_attr.read_new =3D afu_read_config; =20 rc =3D kobject_init_and_add(&cr->kobj, &afu_config_record_type, &afu->dev.kobj, "cr%i", cr->cr); @@ -693,7 +693,7 @@ int cxl_sysfs_afu_add(struct cxl_afu *afu) afu->attr_eb.attr.name =3D "afu_err_buff"; afu->attr_eb.attr.mode =3D S_IRUGO; afu->attr_eb.size =3D afu->eb_len; - afu->attr_eb.read =3D afu_eb_read; + afu->attr_eb.read_new =3D afu_eb_read; =20 rc =3D device_create_bin_file(&afu->dev, &afu->attr_eb); if (rc) { --=20 2.47.1 From nobody Wed Dec 17 19:53:52 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 7F5D42040BF 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=SuuXKm7+oUNJmFswGFnbe1+ioa6JdNnSI/Ski8kf9fF2gbc7k+BL1Rt/+i1J1tsLyqjZJ9A6pXwPVB5uxt3YAShG9+PC3elzy1HsaSKuAiFiEZYW3oEaxwdSkSZQqClDnuDL6GmMd3RDUEw2uIjfphC5DuauQ3AFhxaEIfbcmMU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734348786; c=relaxed/simple; bh=lrmkPttDURFKu0OlFekPYzaHej1ygcR7qwdieg64a/U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AwhggUKxTE/swGVWNNv79dBssHRQKRZCjhhlTWZswPEGZUhq78EpX+8rlusroNScPVn88YE7EJedWC2BueKyNS+hnzmkOF21VrzPJOgLXaEwVw0KphALe7uDMSoJuoyJndH/gzeV+1/m1kwyeIsyRTut+hI9S5NQLvDUPEf1dBk= 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=biRaF6i9; 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="biRaF6i9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734348782; bh=lrmkPttDURFKu0OlFekPYzaHej1ygcR7qwdieg64a/U=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=biRaF6i9GcEtBBhecaVAmJ/d074BoDpxM/yFqI0GiBW2g+6QMvy0rNi/9PoEi4gMV WVcZubEW1Oc+v1/vTNebBWumGkLMcy8+6kLuxnN32eYCQ2oGHueRyuVm3ISf98TDV1 rQ2lyp6vUM5et1FYKhvig4H4UyLAfVLLHdeNqc3A= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 16 Dec 2024 12:32:58 +0100 Subject: [PATCH 3/9] misc: sram: 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-3-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=1550; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=lrmkPttDURFKu0OlFekPYzaHej1ygcR7qwdieg64a/U=; b=vg/FYOfVa/0xZABko9TadSA+Ov/vDdDTdJZ1gLuLI9VX5gubiYiyEKA5sAsk8XZpp2Gy4/gVH I1SUKqTuU5SAto9UpeOJtdEQ+vGj112l9+Gje3A6G+FoiOk6uyqNVEm 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/sram.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c index e40b027a88e25209933a20dc9dbd7db29cb81ba5..e5069882457ef6ba5dc084d0299= 4034dc39d24c6 100644 --- a/drivers/misc/sram.c +++ b/drivers/misc/sram.c @@ -23,7 +23,7 @@ #define SRAM_GRANULARITY 32 =20 static ssize_t sram_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, + const struct bin_attribute *attr, char *buf, loff_t pos, size_t count) { struct sram_partition *part; @@ -38,7 +38,7 @@ static ssize_t sram_read(struct file *filp, struct kobjec= t *kobj, } =20 static ssize_t sram_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, + const struct bin_attribute *attr, char *buf, loff_t pos, size_t count) { struct sram_partition *part; @@ -83,8 +83,8 @@ static int sram_add_export(struct sram_dev *sram, struct = sram_reserve *block, return -ENOMEM; =20 part->battr.attr.mode =3D S_IRUSR | S_IWUSR; - part->battr.read =3D sram_read; - part->battr.write =3D sram_write; + part->battr.read_new =3D sram_read; + part->battr.write_new =3D sram_write; part->battr.size =3D block->size; =20 return device_create_bin_file(sram->dev, &part->battr); --=20 2.47.1 From nobody Wed Dec 17 19:53:52 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 43D5B20458B 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=1734348785; cv=none; b=G3Q0CXVAHW1peeLdeYrq4Cmw00MzTi8ccGDpfGFwwGw/FkktsRskb2AeY54Kknvw5+kPn/2GFLG5cMR9xHagQg58e5hhsgoq7YAEtWrVR4gvGIf7j40xYiFo6xiUt7a7U7YDQNA36jkVe3nIpAyPTHKv5t6Isp6XXzuKSjhISWA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734348785; c=relaxed/simple; bh=CcDBWMFWLtSDmVrkWX7ndeD+K4Cfvo9MPzDfwHVQP6g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XXGw9m+IZH8YWh5XVj6v9GIJ6DxAnqWEw1DIMPnUnotGQBdTyDI5n63FLMTgqwxY6189F8I4DZJSb2kfAXj+CcnR23rPevl3oSJsmkOMhdUg5nQmzbas9IG9Uq/qh5LOk7Dp0ENeEIgXKWWiL7WuYEUbyMLCXm+rgdnjh1QO+VA= 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=myKGpY3u; 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="myKGpY3u" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734348782; bh=CcDBWMFWLtSDmVrkWX7ndeD+K4Cfvo9MPzDfwHVQP6g=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=myKGpY3uWk6mwmbD2RvdisauS0ytwt05mIhLyKQcE1VG7wh/xYWLoEr0YYP2vsSvW D4PIIqYUs0bRIlZzV3Ea3YKF4lLEEYqqb4zYUNjHq0MV2KwNaNXw5lfJagNObcfoI+ StpUSP1/JX9+gLr3dSwB1yKOWc8H1wTNkKpdd+20= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 16 Dec 2024 12:32:59 +0100 Subject: [PATCH 4/9] misc: c2port: Calculate bin_attribute size through group callback 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-4-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=1494; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=CcDBWMFWLtSDmVrkWX7ndeD+K4Cfvo9MPzDfwHVQP6g=; b=V3cSwsQHSCtQbrD0jp5/nVa8t1w9RANvtZ0CKl4QibCNmCl3FskR+zYeGXktanFJ1i5WvyyI4 ov9YBDN+vVKBxcdOP0J8TnBHLO2TcmINCzJwbVmkUQGjVAvJb8LSslR X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Modifying the size of the global bin_attribute instance can be racy. Instead use the new .bin_size callback to do so safely. Signed-off-by: Thomas Wei=C3=9Fschuh --- drivers/misc/c2port/core.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c index 2bb1dd2511f9dd178b8c06baa460bb609f7f8fd7..5d6767b484c998b44a3c90c177d= 12028db1ea1af 100644 --- a/drivers/misc/c2port/core.c +++ b/drivers/misc/c2port/core.c @@ -874,9 +874,22 @@ static struct bin_attribute *c2port_bin_attrs[] =3D { NULL, }; =20 +static size_t c2port_bin_attr_size(struct kobject *kobj, + const struct bin_attribute *attr, + int i) +{ + struct c2port_device *c2dev =3D dev_get_drvdata(kobj_to_dev(kobj)); + + if (attr =3D=3D &bin_attr_flash_data) + return c2dev->ops->blocks_num * c2dev->ops->block_size; + + return attr->size; +} + static const struct attribute_group c2port_group =3D { .attrs =3D c2port_attrs, .bin_attrs =3D c2port_bin_attrs, + .bin_size =3D c2port_bin_attr_size, }; =20 static const struct attribute_group *c2port_groups[] =3D { @@ -913,8 +926,6 @@ struct c2port_device *c2port_device_register(char *name, goto error_idr_alloc; c2dev->id =3D ret; =20 - bin_attr_flash_data.size =3D ops->blocks_num * ops->block_size; - c2dev->dev =3D device_create(c2port_class, NULL, 0, c2dev, "c2port%d", c2dev->id); if (IS_ERR(c2dev->dev)) { --=20 2.47.1 From nobody Wed Dec 17 19:53:52 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 51F99205ABC for ; Mon, 16 Dec 2024 11:33:07 +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=1734348789; cv=none; b=Cc3S9a+LNOG8sEOzkhz7oiPGKp6r0jEpsvRnOTlN6SAGILQTT8kOSvmFQAnvC/PGjSSOfzoe/CevkaIOmZpfeLNB9LwXUjpVtmPDitkPqJ4jdkd85jlDgT4BJdivw+JtbAxVVrPaqg/L7B6hbUKTVwfpT+tcsklYcIYxE8HS/TE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734348789; c=relaxed/simple; bh=8m1RQ3DhfA9f6hdRy+DqOXn1T98rVvXAkNUHHyC1n88=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WxzTSLmTwKyk8ds2jbU8FbWiCQnn+jEEGpM4/4SczCocVgxEn1iEyIY1cs0y+hwQrYQpOiE73hiliTRZeGk5ORuk0LsGVuSKuk7YVQ1sVvf5MsJNV90tJaLpBxrh8ogCof3HV1UYBkXkyrQ27yPucqq4APANTFI2+5K42lJwBc8= 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=SfkGxAQc; 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="SfkGxAQc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734348782; bh=8m1RQ3DhfA9f6hdRy+DqOXn1T98rVvXAkNUHHyC1n88=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=SfkGxAQc9gPviIOEmy4LRe1MEdM+uibGvmTgCiGkHbfX969bE+uuzDsv7wi2aVMMr DRsuS81JPJO9/FhetrzfPoLM4SyqfjJCWgcRhNLYM4/fMv66PMmqt5rZdoW3UYqwPa AZty3dWGEvw2A1Szvx96eaaIHcdip8YJCBTUxud4= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 16 Dec 2024 12:33:00 +0100 Subject: [PATCH 5/9] misc: c2port: 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-5-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=2244; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=8m1RQ3DhfA9f6hdRy+DqOXn1T98rVvXAkNUHHyC1n88=; b=BcUHlLFzhkKMOTNksv+oFkNkaEG/oNFfc71yOk0a4fCYqm91WEtMRhVsrdt1ABPa80jDGdlEw 4U8JXjI4XnYCQDnpOJtBeyWF1JDi8sdGib54AvjHTZ0dDI4bMwgX+rx 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/c2port/core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c index 5d6767b484c998b44a3c90c177d12028db1ea1af..eb780e635352f3a815e8d400d71= c04b47507cd4b 100644 --- a/drivers/misc/c2port/core.c +++ b/drivers/misc/c2port/core.c @@ -714,7 +714,7 @@ static ssize_t __c2port_read_flash_data(struct c2port_d= evice *dev, } =20 static ssize_t c2port_read_flash_data(struct file *filp, struct kobject *k= obj, - struct bin_attribute *attr, + const struct bin_attribute *attr, char *buffer, loff_t offset, size_t count) { struct c2port_device *c2dev =3D dev_get_drvdata(kobj_to_dev(kobj)); @@ -829,7 +829,7 @@ static ssize_t __c2port_write_flash_data(struct c2port_= device *dev, } =20 static ssize_t c2port_write_flash_data(struct file *filp, struct kobject *= kobj, - struct bin_attribute *attr, + const struct bin_attribute *attr, char *buffer, loff_t offset, size_t count) { struct c2port_device *c2dev =3D dev_get_drvdata(kobj_to_dev(kobj)); @@ -849,8 +849,8 @@ static ssize_t c2port_write_flash_data(struct file *fil= p, struct kobject *kobj, return ret; } /* size is computed at run-time */ -static BIN_ATTR(flash_data, 0644, c2port_read_flash_data, - c2port_write_flash_data, 0); +static const BIN_ATTR(flash_data, 0644, c2port_read_flash_data, + c2port_write_flash_data, 0); =20 /* * Class attributes @@ -869,7 +869,7 @@ static struct attribute *c2port_attrs[] =3D { NULL, }; =20 -static struct bin_attribute *c2port_bin_attrs[] =3D { +static const struct bin_attribute *const c2port_bin_attrs[] =3D { &bin_attr_flash_data, NULL, }; @@ -888,7 +888,7 @@ static size_t c2port_bin_attr_size(struct kobject *kobj, =20 static const struct attribute_group c2port_group =3D { .attrs =3D c2port_attrs, - .bin_attrs =3D c2port_bin_attrs, + .bin_attrs_new =3D c2port_bin_attrs, .bin_size =3D c2port_bin_attr_size, }; =20 --=20 2.47.1 From nobody Wed Dec 17 19:53:52 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 From nobody Wed Dec 17 19:53:52 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 F220F20551F for ; Mon, 16 Dec 2024 11:33:06 +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=1734348788; cv=none; b=F8ed7gVbdTBWbkTvoF3ivEhoE2t9csmQgvsL/EfI0h6Uyg4EmHxhtIrLnj9DVAYSAuX7NGsuyzJkYUySXFpYDmoNFDN1TML8y5grJz3RnTNApb0ZzmUeqlvBdrEtfngDg8q3MEExol8362strJrdF1ZDv6s09dR8vq+gA//MWUM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734348788; c=relaxed/simple; bh=SGNU5IH45oWd8l2/U8DWBMgp52g/CAQH5eqzkYxnU98=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sV5ege/PMV2VMqx2zIFW5qCuo2583u045/R0eJ+dtUy3K3sy8oR/tivRE3zzVQ4Ro4JhWF2fb975tnMoyWsYxjunZ0XAJt1OhlLOkUkbG/VR2xSaQ/DXidAljPJxIC6tfOoA1bhoNaxrLb/3q8GlAnGDli0QbomMj95a7PU5p2A= 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=c3mYq2mJ; 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="c3mYq2mJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734348782; bh=SGNU5IH45oWd8l2/U8DWBMgp52g/CAQH5eqzkYxnU98=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=c3mYq2mJcekiJuhBgIIW27jXtnpzPT4YWscUJ2HP5DhUmVlnXWvFi+N42GdoVqI8C eRRGwl70Gcq/YAiALSTicS2w9RrHzN2ZIYyhsuRox+eKdeMgTIGZdlaWpCqKw2mzla Cd0K9z8QHx8LKszbT1NmV/lc7Y0GSLW1DySkfs/o= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 16 Dec 2024 12:33:02 +0100 Subject: [PATCH 7/9] misc: eeprom/idt_89hpesx: 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-7-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=1790; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=SGNU5IH45oWd8l2/U8DWBMgp52g/CAQH5eqzkYxnU98=; b=g8NH5MD7iQwipA2t3S5AFXTfyVoMJXZLw4AUNZ66awjEngV+bDzzXZSYF66Pl7unnvvTkaHQm L88qMM11/C4DkttBTBl8msv5BNPFGUgTCF2PNY/OqhAHX5VvqqD5uTD 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/eeprom/idt_89hpesx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/misc/eeprom/idt_89hpesx.c b/drivers/misc/eeprom/idt_89= hpesx.c index 43421fe37d338874ff1c2949497c64ebf0143106..1fc632ebf22f560088084519e5a= d8e8b37958368 100644 --- a/drivers/misc/eeprom/idt_89hpesx.c +++ b/drivers/misc/eeprom/idt_89hpesx.c @@ -847,7 +847,7 @@ static int idt_csr_read(struct idt_89hpesx_dev *pdev, u= 16 csraddr, u32 *data) * @count: Number of bytes to write */ static ssize_t 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 idt_89hpesx_dev *pdev; @@ -871,7 +871,7 @@ static ssize_t eeprom_write(struct file *filp, struct k= object *kobj, * @count: Number of bytes to write */ static ssize_t 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 idt_89hpesx_dev *pdev; @@ -1017,7 +1017,7 @@ static ssize_t idt_dbgfs_csr_read(struct file *filep,= char __user *ubuf, * NOTE Size will be changed in compliance with OF node. EEPROM attribute = will * be read-only as well if the corresponding flag is specified in OF node. */ -static BIN_ATTR_RW(eeprom, EEPROM_DEF_SIZE); +static const BIN_ATTR_RW(eeprom, EEPROM_DEF_SIZE); =20 /* * csr_dbgfs_ops - CSR debugfs-node read/write operations --=20 2.47.1 From nobody Wed Dec 17 19:53:52 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 EE55120550E for ; Mon, 16 Dec 2024 11:33:06 +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=1734348788; cv=none; b=M63RlZytGAH1U4Bey6ZdzZ1cUIqxHQf+yPKWPgpyfBRZio2W+rkwD5gpTR9PejlBySKL7aVZigvAqlOrZYDfnBFBg/v5JRBVi8ZGKs5snc8vCRcODK20xD3oPg4Xmq/C5ViHwdRihBssffazHniUTi+hvtNHgGfk6UsuCP16mQs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734348788; c=relaxed/simple; bh=P5yp8xYY8rjGfFuGyyUiA1DeB8eRe4QDxQgMbEH9sX4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=P9G01z4VbiTDxiUhKgh9txXUQ/R+hKeB1pfo5qi2oDMf7qDAtT1pIZ2m0/yYdx7iIeGBWTb1NANGZqisUxrhdOXoA7sFiJTQp/4vMHgPAsLU1LljWuOl1/8CgJ8GTYGmgCkrxQosBz8Bpq3Fe8jWD0tQz4dVsZDRI8mHkI0kPAc= 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=svVmtvaE; 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="svVmtvaE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734348782; bh=P5yp8xYY8rjGfFuGyyUiA1DeB8eRe4QDxQgMbEH9sX4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=svVmtvaEfVKWlI8VZwfYj66iHqRaO9PnQVSWrmsw4BujiyUQ+yko3HpWl4Dl1hkWB 5lkzEWLtizIAVIHU0EJsQ3SUY7mzGJTbzn38cGo4rpCCm/H6eD+4c/tweUanj8Stz1 u09BB8wsiP6LvSqot8lM67B0ywl2z3xoqRFkxljk= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 16 Dec 2024 12:33:03 +0100 Subject: [PATCH 8/9] misc: eeprom/max6875: 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-8-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=1212; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=P5yp8xYY8rjGfFuGyyUiA1DeB8eRe4QDxQgMbEH9sX4=; b=k7/JQA7TzOn/tnIeXdQZ/clBNOPvkBekXegG3kZ5eiGbNYKtRRCJtibmbDT1eNMQHtuOt/QMq jszYpZRVM+iAkaXxT6+Rw3UkJHgxAHt3vZgEkhmIAc06ICDAljy8us1 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/eeprom/max6875.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/misc/eeprom/max6875.c b/drivers/misc/eeprom/max6875.c index 6fab2ffa736b741593931c413f230d7c43b5b8dd..1c36ad153e783ead6ba2481c648= 38390f0bb05f4 100644 --- a/drivers/misc/eeprom/max6875.c +++ b/drivers/misc/eeprom/max6875.c @@ -104,7 +104,7 @@ static void max6875_update_slice(struct i2c_client *cli= ent, int slice) } =20 static ssize_t max6875_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) { struct i2c_client *client =3D kobj_to_i2c_client(kobj); @@ -127,7 +127,7 @@ static const struct bin_attribute user_eeprom_attr =3D { .mode =3D S_IRUGO, }, .size =3D USER_EEPROM_SIZE, - .read =3D max6875_read, + .read_new =3D max6875_read, }; =20 static int max6875_probe(struct i2c_client *client) --=20 2.47.1 From nobody Wed Dec 17 19:53:52 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 9FB37204599 for ; Mon, 16 Dec 2024 11:33:07 +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=1734348789; cv=none; b=QrbzB9e0t1phl+FaAs4oebbn8Md34yDF3eQM9of0SBENHEQPHtC/dwdmSV3B83S1gqLG6tnn1uX2XZ/abOMYVBnyGKr3MR7sqWKyf3YN4YDiA279z6zcVvOzH2O3kJZk5PEe0Kl9kaCbIE5J7YP6a1GlCKGIcKJrqNpuMzKxdZo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734348789; c=relaxed/simple; bh=K4ArLdURdX68J2n0OD7NKA61+TDFNtIXruvjgSApS6k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jlSZnEs7ZDr86OnGb4TWdEWN2s4iVzZoYeBrIsahKmPtp/gKipILFncVLmpvu29VG0jQKWOCyAJcKkElteZ6Jr+Ogld0ME5jbsL2IK78buopPDNaG+dozwwZW3HmLFskmZVb5TpBYYGwU5Q5mwmVG5mmq6Es8s1mmWSWy0hVJSE= 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=NfxFD6II; 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="NfxFD6II" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734348782; bh=K4ArLdURdX68J2n0OD7NKA61+TDFNtIXruvjgSApS6k=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=NfxFD6IIfv0b72FnNHcUemUJKW7ucb4PD4uqSFqSynxbBJ1SFm8Ol1Sv7jwELRPFE 749g1byC+LOX+bRy4uE6sridAEUEEZzgWFKpTEm6Voj+AnXNWP8H4ppwKng/R0X08P v5cPrKAYHLUWz/wmrCIA3gqttNBQATRla42PJpY0= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 16 Dec 2024 12:33:04 +0100 Subject: [PATCH 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: <20241216-sysfs-const-bin_attr-misc-drivers-v1-9-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=1662; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=K4ArLdURdX68J2n0OD7NKA61+TDFNtIXruvjgSApS6k=; b=vnav+SRhHMJUpON2XxNPS9SvCbHCVXWtEVYujeOfGn+lPW1BTFAAtx1VDP0H2bZFBSIJAl63w ei68QXNXhzlD7MjpC5Xdlp+pHXf2dPAekPEInby2gxMr4OzqQ7toj+/ 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