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 95F511F37C0 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=BBL3eXGxQRk1wDaKZfHW2xtXZJkDVpNHd6XJyJFPee1zHmFePIldg/C1qi1Zu7BZjps/ye26bYn6MmzKA00lH8VR4LSb8jsyFfbrrYQ482Q/KBQp5+iZb9sL7lj9W9bx842F0oxtnecUBkoBYXcD/v0Rxo6kZCrmYJmx2I7f/Wc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734792495; c=relaxed/simple; bh=lrmkPttDURFKu0OlFekPYzaHej1ygcR7qwdieg64a/U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=L5JDWna4oX92cU8UwHMAS46eoDbT3uRxlkCWfzXHyurztHV5d48mJDEUNBXtS5c7HbIJ33FTF+9HbttcD8iLQfXrLi/GL1kgEEFhoriKyA6PnO2q9CHa3ZFitrr/qKFM9e3K6tzvlYbPCnWwlsbdhnFWzmOMoKEdIgDofMyQe8c= 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=EWtNXKai; 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="EWtNXKai" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734792491; bh=lrmkPttDURFKu0OlFekPYzaHej1ygcR7qwdieg64a/U=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=EWtNXKaiesE5iymgb6Nx8YvZuEAPf9vYASG1fjoU46cjYroVYOuoHCLLUTYybsOc1 BsxvOei373DqCAw8R3zXSBeo8XXGoBK5r8n71NytzfbrmYZGnr6WMsBFDiSFveF4vi pNuYVuSoHtfZNDOl2WWMu+9tql0AsAEtAXsaUvmk= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 21 Dec 2024 15:48:09 +0100 Subject: [PATCH v2 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: <20241221-sysfs-const-bin_attr-misc-drivers-v2-3-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=1550; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=lrmkPttDURFKu0OlFekPYzaHej1ygcR7qwdieg64a/U=; b=bdSQV5Q6IhmFAaIFeRAfk/SbSV3IqpAh93NP3WZkXM1uYH6quaPwdVCV+1MdEt9keWOo8kNPu o5bEK7MDyKoAEUDUsmbDpHz8ivH+xXGdj40OWuHG0gpN5H4u8iIc2LA 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