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 F2C2F33FE for ; Sat, 21 Dec 2024 14:48:12 +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=1734792494; cv=none; b=LWZ8blvo3yWSI6U7gWC/TgPPsRGlfKY4qp+BNQlVsP/JNSX0iugdwohV8WutwBW/uIFMIPCyFnKxFC73OQhjqS13ASaFriaA5G2fveoDqmKAFdluTO5AZOPplgCuN4RETfnEDwx7FTSiNnkXyhdkO6zCLS9LeH1mxQVf/y/WIs8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734792494; c=relaxed/simple; bh=HdhEo0+3qt1XAEQ2OvK1EVfCCKLrCDFgHBMKfkRiFtc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ugZo6dvt3u4uBMTOrB3JRqnNw3Vh4zzw0jgdX3oDc68jy0xC3RJ+7vURg9aLGrnoJpY38Nn259cnaNVGJINtkFkjwG+u3OxEBXQl8T4mmF9DymJOESbN/25lStVOWfoP2zAxN6TzzEfsweLj/3/O/veti9XyueG1crKDfuvN56w= 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=LNg9OD6K; 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="LNg9OD6K" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734792491; bh=HdhEo0+3qt1XAEQ2OvK1EVfCCKLrCDFgHBMKfkRiFtc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=LNg9OD6Kr8itKOZKhpX6flzRmPnildZpCIg/HAjDHrQx9R4odaRnx6dZcGuhsjVAZ oUSmhmnDx3juaBAT34M/+2MyIVEEWVl6yD6kV5boUS0Tr9JbKK+zV/XdOPy508v/gi IVjtwSLoppZPloW1TgYIP/2OsUb0MI7NdRFcfp4w= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 21 Dec 2024 15:48:07 +0100 Subject: [PATCH v2 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: <20241221-sysfs-const-bin_attr-misc-drivers-v2-1-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=1457; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=HdhEo0+3qt1XAEQ2OvK1EVfCCKLrCDFgHBMKfkRiFtc=; b=FdmsEIMeigKQSa0j6GAYjlnflM/7EQ6hcX2TirjlZzlbp4oPUluc4uCjBR/gbYPZjqTrAc+N0 msW6nBb7a31A5r2IQxSAS4yORFYgZgxxkDBLJ2zAXEopFKpLUgc16/r 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