From nobody Mon Feb 9 16:02:30 2026 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 6F0901DC9A8 for ; Sat, 25 Jan 2025 10:12:17 +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=1737799940; cv=none; b=mvuiLa+GSIo+//uLpkxgY+3ZMIQQ520QArL0VyulZrr3CpeZjQEl4WT0YQxRBKn7XCHcWGk31dVoMmtJEc34sCoANtihStOzGbZibRqVu+4Mv8Xz60h6uwB2CYwxEgSblrSrii/EpvZd/EeJLpYPEfnMiSZu1Kaw2ZpwAHN4y4Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737799940; c=relaxed/simple; bh=YuJfuT5c39Ro0sX7JVL/Z+OzZFl95TdZcuzPOLuz5HM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nS/QNwzcNifHW7KzxQJuJxw+nraj+lNVFMntrTQm4wAyrUzSYhNLYUfN9lgLLutlQ4BFF9l1Sxv74T8Ait73kz0u3iEDLySSPjjaQuosNhpmvDtT4veuY8oyHOTe0WWPdAIBG5Ro9e/o23Dwg9cK80mzA0qW4M0PGf5F7K3QnvI= 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=MqdVHl7v; 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="MqdVHl7v" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1737799935; bh=YuJfuT5c39Ro0sX7JVL/Z+OzZFl95TdZcuzPOLuz5HM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=MqdVHl7vBoM/YTqXJoBEizAjCs4jxnKHW9qjzWg8UzMBO8giU6BIAQIivaAuULlE8 qNYSjZBAOvcqNIiCI2dTwiDa1bO/sIw4RGf5Dzj08Mxk7oa2fa6G0XNYKgMEuMvn0Y N6Bdu5y/lNwrBUvY+mA7WFyKte1fqPYz3XNIREEA= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 25 Jan 2025 11:12:16 +0100 Subject: [PATCH v2 3/3] firmware: dmi: 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: <20250125-sysfs-const-bin_attr-dmi-v2-3-ece1895936f4@weissschuh.net> References: <20250125-sysfs-const-bin_attr-dmi-v2-0-ece1895936f4@weissschuh.net> In-Reply-To: <20250125-sysfs-const-bin_attr-dmi-v2-0-ece1895936f4@weissschuh.net> To: Jean Delvare Cc: 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=1737799934; l=1649; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=YuJfuT5c39Ro0sX7JVL/Z+OzZFl95TdZcuzPOLuz5HM=; b=qtYaJZm5KkufQr7v231/N55UV1ZEpVeseI+fNJdJ/GoaBQTdPP4LSu46GrzEyquofa97PccIF a/EFz79l3p+BpZnvyhxipZ/8KQLmJCE0+PCdTvHCzqfXqY4sEu6gVnC 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/firmware/dmi-sysfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/dmi-sysfs.c b/drivers/firmware/dmi-sysfs.c index 6baa921a6664d087049bc15bf44a32c520853526..9cc963b2edc0e9a0e9a7b03af71= 74c08e8ea9422 100644 --- a/drivers/firmware/dmi-sysfs.c +++ b/drivers/firmware/dmi-sysfs.c @@ -432,7 +432,7 @@ static ssize_t dmi_sel_raw_read_helper(struct dmi_sysfs= _entry *entry, } =20 static ssize_t raw_event_log_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, + const struct bin_attribute *bin_attr, char *buf, loff_t pos, size_t count) { struct dmi_sysfs_entry *entry =3D to_entry(kobj->parent); @@ -445,7 +445,7 @@ static ssize_t raw_event_log_read(struct file *filp, st= ruct kobject *kobj, return find_dmi_entry(entry, dmi_sel_raw_read_helper, &state); } =20 -static BIN_ATTR_ADMIN_RO(raw_event_log, 0); +static const BIN_ATTR_ADMIN_RO(raw_event_log, 0); =20 static int dmi_system_event_log(struct dmi_sysfs_entry *entry) { @@ -536,7 +536,7 @@ static ssize_t dmi_entry_raw_read_helper(struct dmi_sys= fs_entry *entry, =20 static ssize_t raw_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, + const struct bin_attribute *bin_attr, char *buf, loff_t pos, size_t count) { struct dmi_sysfs_entry *entry =3D to_entry(kobj); --=20 2.48.1