From patchwork Sun Dec 15 14:49:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13908782 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 6B66118D63C for ; Sun, 15 Dec 2024 14:49: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=1734274159; cv=none; b=t+ZNwq/ieKl/dyQE8a4BA5HNzO60Mazf5zb9k23Z6e+0hlQYTNjBEQsAX8yRTbwuZMXrj44SbFwX1J2BGRrQrs4i1pypKtOrHrqtviII6y7xjqrWWikH5vG9M/SsMSHdM4LMDRi1ICDRJfxNpCa09s5WXU1ikVjy6gekuwMCFnw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734274159; c=relaxed/simple; bh=OD/lWja0joVP9SVburnkmOGS1hQtirbqWB+jWss8JFI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DdNxD2ZU5+tKILPBK1NkjtYBMIwU3a7Z6azYTm8ojAi/tswZVH49HAduzrUuxDYYhXwtVHrVH+1Y8U90q1C+WfmfSFSukemplic2dVVbcK7pEWMP1C+vFGVK4vvzrjeWSJIW4JTDNbSOU7VbLd1z1TWeUmCn5pwqerVa3WMKVew= 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=eWO3aJxh; 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="eWO3aJxh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734274154; bh=OD/lWja0joVP9SVburnkmOGS1hQtirbqWB+jWss8JFI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=eWO3aJxhDiFpDpZ7akFcpN4b6hIZ1NSOM5B9SaMNeEk/xFyHqqGvg0eTRfxZQaN5j R7h0H1q/bGqkMu5Q3nVSAxZYspFMmTcm4NfVDSnGVRtckHi7T14dgXh1yBy3K8ts0N /qs+tBA7XEq6G5ttrL0wktU7451yhQLDnJKebcgw= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 15 Dec 2024 15:49:10 +0100 Subject: [PATCH 2/4] firmware: google: gsmi: Constify 'struct bin_attribute' Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241215-sysfs-const-bin_attr-google-v1-2-e5c2808f5833@weissschuh.net> References: <20241215-sysfs-const-bin_attr-google-v1-0-e5c2808f5833@weissschuh.net> In-Reply-To: <20241215-sysfs-const-bin_attr-google-v1-0-e5c2808f5833@weissschuh.net> To: Tzung-Bi Shih , Brian Norris , Julius Werner Cc: chrome-platform@lists.linux.dev, 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=1734274153; l=1375; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=OD/lWja0joVP9SVburnkmOGS1hQtirbqWB+jWss8JFI=; b=zoty251LisZOy9nkLs5RVC6Mdj1bppEadFFAktrMHWMQjivkuIrddKYlBft+ziH7xs15NyFr4 oSrUsxQqMavA2cs+mZtwNc6Edz2U9UR/vI3/qyuaD80ezUQF1ZUtphJ 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ßschuh --- drivers/firmware/google/gsmi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c index 24e666d5c3d1a231d611ad3c20816c1d223a0dc5..e8fb00dcaf65bc593dd15562f20aeea482ccfc3e 100644 --- a/drivers/firmware/google/gsmi.c +++ b/drivers/firmware/google/gsmi.c @@ -488,7 +488,7 @@ static const struct efivar_operations efivar_ops = { #endif /* CONFIG_EFI */ static ssize_t eventlog_write(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 gsmi_set_eventlog_param param = { @@ -528,9 +528,9 @@ static ssize_t eventlog_write(struct file *filp, struct kobject *kobj, } -static struct bin_attribute eventlog_bin_attr = { +static const struct bin_attribute eventlog_bin_attr = { .attr = {.name = "append_to_eventlog", .mode = 0200}, - .write = eventlog_write, + .write_new = eventlog_write, }; static ssize_t gsmi_clear_eventlog_store(struct kobject *kobj,