From nobody Wed Dec 17 21:41:10 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 45DC144C76 for ; Sat, 21 Dec 2024 14:48:13 +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=1734792495; cv=none; b=roeEJs1kzK4ILpD6G8htms5t/+c5tYwy9CZ0l5IlTR1s2ElvtVK6Z4+PS+HJLctySHn+gTxFtu5ifbRNDGzg4bk6f2wZvUWLt5qEKYIjV1YuySKUnmeLKqIzBgC349v729ROH2Rd6tJKuZ+7WE67PGoJ79s1UTlG+Cs5hZEHWLY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734792495; c=relaxed/simple; bh=RwAfPP9M2GhUNJqftttiOezg9EgAoMngS2VyEVuwqHs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=i5ut2AHQdwT+GmDrSWTI9td19P09PVOOz/rQERmhhdoZ5Gy8AsMAvePftWgFS98tz4ocd5wEwtedCFJrWyqOMkJbXLChdE0e0cV9/Zp6YSBGs55yGLXa6i4iGX1G38pkO9e4r1M2P/IJywagKo8BlrVS2GhB18XWGTTwNG9cjJ4= 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=qVGDyzQZ; 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="qVGDyzQZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734792491; bh=RwAfPP9M2GhUNJqftttiOezg9EgAoMngS2VyEVuwqHs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=qVGDyzQZaxTjxePLqqeh0PYSAauLlAcjAXx21OS2ucpxW4E03kDA0WdkQRdWNsl88 udXSOBR16ID1YWkjIr0AufMMs2Ku8WzR7bavJB4l2dPQziEFpN0UheYAdatzE1Abs1 DoY+M4cTZCmt2CpaPca47FvKgg0vWYMc+hoP3Lmo= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 21 Dec 2024 15:48:08 +0100 Subject: [PATCH v2 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: <20241221-sysfs-const-bin_attr-misc-drivers-v2-2-ba5e79fe8771@weissschuh.net> References: <20241221-sysfs-const-bin_attr-misc-drivers-v2-0-ba5e79fe8771@weissschuh.net> In-Reply-To: <20241221-sysfs-const-bin_attr-misc-drivers-v2-0-ba5e79fe8771@weissschuh.net> To: Frederic Barrat , Andrew Donnellan , Arnd Bergmann , Greg Kroah-Hartman Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734792490; l=2119; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=RwAfPP9M2GhUNJqftttiOezg9EgAoMngS2VyEVuwqHs=; b=OkQn3R2RgNSCuhxmhVduMnO3k9hbmoJYC3K9thYJkN5ETqHzqu+V+OfVYJG0JVRpk5GW8TBt2 ziTNFgrLzVwAyY+jJVAUWvFmpvzYInLJxoUxqpIXqGJBrcxDdtFMLEh 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