From nobody Wed Dec 17 21:40:58 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