From nobody Wed Dec 17 18:01:15 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 8419C18039 for ; Sun, 15 Dec 2024 14:49:16 +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=1734274158; cv=none; b=Qk0LFGp0fAgsWLmguZd/ZmfLFSgtpsBSaym8SUhCQaH4Xsfk8ecTAOo7hvFeOzLSWHiBbOTzOy3e5ryS7PlZMkmhkr9ngU4qkE45N2RgSpKyL5WI2gy2faiuccJA/1ARDvtNLUtlUhC0WWUJJbzs7/0cAMj6jq08LpqCB40Xo7M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734274158; c=relaxed/simple; bh=BOpBAV2k4jTrjMyus8d4jUCKCV1/z/2Q5Zkgqy8lyX8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gYyXhV7FWrzqiba2M9Sf3IdKwgih8kHOFF2Wopa2+w6R5lTi92a+wRVDsh6Q+/2731V1/mCPH5CRU0p7en6JNWmWr+Pe2RHE3rb3DB0O/gI8Ak/41MbB4BBpVu72Xg2Er8MqHTePaguUaOr52U06X8Ozu65JVBBiAbviGzgtDik= 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=IqgtwNum; 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="IqgtwNum" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734274154; bh=BOpBAV2k4jTrjMyus8d4jUCKCV1/z/2Q5Zkgqy8lyX8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=IqgtwNumuDG6hu6iAXyqGtVi4UezcQqgWPszbQmzZzDKAcuat9abCB2fLs20b+00d gCFhlEYZd8QKP9JpG3lf/nk62dP5MtMfq615pcmH6M6NNrwZhQ4vrMsE96szUH9kEG JxIDX9O5e2jJuhlPYUQs3jK4ik57vwmnlWXnX6/g= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 15 Dec 2024 15:49:09 +0100 Subject: [PATCH 1/4] firmware: google: cbmem: 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: <20241215-sysfs-const-bin_attr-google-v1-1-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=2094; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=BOpBAV2k4jTrjMyus8d4jUCKCV1/z/2Q5Zkgqy8lyX8=; b=EH8oiUeEjnDvdJqmUlSU2D4BtirI9kbHItut16hk9OkQC5wyFv/tUL4QVNdQUMGm1biH89wKW wZib3mqc3sQC3VM+39+CUqy2w7aUp2au7494DIm8pMuFTBiUauxDKCK 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: Brian Norris --- drivers/firmware/google/cbmem.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/firmware/google/cbmem.c b/drivers/firmware/google/cbme= m.c index 66042160b361fe2a2d9599880a96d5de14b7128d..773d05078e0ae0763591a6d9cfa= 0d55ea5fff611 100644 --- a/drivers/firmware/google/cbmem.c +++ b/drivers/firmware/google/cbmem.c @@ -30,7 +30,7 @@ static struct cbmem_entry *to_cbmem_entry(struct kobject = *kobj) } =20 static ssize_t mem_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, loff_t pos, + const struct bin_attribute *bin_attr, char *buf, loff_t pos, size_t count) { struct cbmem_entry *entry =3D to_cbmem_entry(kobj); @@ -40,7 +40,7 @@ static ssize_t mem_read(struct file *filp, struct kobject= *kobj, } =20 static ssize_t mem_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, loff_t pos, + const struct bin_attribute *bin_attr, char *buf, loff_t pos, size_t count) { struct cbmem_entry *entry =3D to_cbmem_entry(kobj); @@ -53,7 +53,7 @@ static ssize_t mem_write(struct file *filp, struct kobjec= t *kobj, memcpy(entry->mem_file_buf + pos, buf, count); return count; } -static BIN_ATTR_ADMIN_RW(mem, 0); +static const BIN_ATTR_ADMIN_RW(mem, 0); =20 static ssize_t address_show(struct device *dev, struct device_attribute *a= ttr, char *buf) @@ -79,14 +79,14 @@ static struct attribute *attrs[] =3D { NULL, }; =20 -static struct bin_attribute *bin_attrs[] =3D { +static const struct bin_attribute *const bin_attrs[] =3D { &bin_attr_mem, NULL, }; =20 static const struct attribute_group cbmem_entry_group =3D { .attrs =3D attrs, - .bin_attrs =3D bin_attrs, + .bin_attrs_new =3D bin_attrs, }; =20 static const struct attribute_group *dev_groups[] =3D { --=20 2.47.1 From nobody Wed Dec 17 18:01:15 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 17710189F56 for ; Sun, 15 Dec 2024 14:49:16 +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: 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: <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=C3=9Fschuh Acked-by: Brian Norris --- 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..e8fb00dcaf65bc593dd15562f20= aeea482ccfc3e 100644 --- a/drivers/firmware/google/gsmi.c +++ b/drivers/firmware/google/gsmi.c @@ -488,7 +488,7 @@ static const struct efivar_operations efivar_ops =3D { #endif /* CONFIG_EFI */ =20 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 =3D { @@ -528,9 +528,9 @@ static ssize_t eventlog_write(struct file *filp, struct= kobject *kobj, =20 } =20 -static struct bin_attribute eventlog_bin_attr =3D { +static const struct bin_attribute eventlog_bin_attr =3D { .attr =3D {.name =3D "append_to_eventlog", .mode =3D 0200}, - .write =3D eventlog_write, + .write_new =3D eventlog_write, }; =20 static ssize_t gsmi_clear_eventlog_store(struct kobject *kobj, --=20 2.47.1 From nobody Wed Dec 17 18:01:15 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 A1FAF18FDD8 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=1734274160; cv=none; b=CJO50lBD8zfGu4wM6EPr3TjYU40/ShNb+QQImK9EoWpgVBSnMhqDMhYR78wENJ8JrSYV/u6WWiY+NlWsv10/bBJRp4np+YWcLoNh7DqvB2+a5lDZuyfwvVQ7y8B8OQZiibTLkLFPALOoeff63ftNz+VFiwJbRqvf4MLT6uGrU/w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734274160; c=relaxed/simple; bh=GPoO2MlSyFN41keL/IQMHVzwngO96d3fyeoIVD73xh0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UyWqdXZVaQZa51pm4pF7Pplwh+4yYHgWV/3796FD8gMHcGiuyVtKZyItjTnPNXMmcA6IX/fUSfuqAyRr/x/hkpTExCbTSuai108HxiiDbx0z+raVSL0HqrOCbHZY/Jkb+Dh/0r2EejRhGHUJrVh3RszHoJUYzgPb2e9ZvnDzSZI= 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=kqrI1soz; 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="kqrI1soz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734274154; bh=GPoO2MlSyFN41keL/IQMHVzwngO96d3fyeoIVD73xh0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=kqrI1sozDNK2AvehZaV6vrnPcQnHjIX63VWtGVuX5PrnIRydf37SmfuXcC50KMzU1 VrO/QF2HovWq9imz0jt17WDBYaJK57fGEVwE6WfRYegxu1J9N1cgqt8l0KGfGkzMmK IEbkdHc9pulhDogINALIBHxIPlhnl3aAAVr/mq/Q= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 15 Dec 2024 15:49:11 +0100 Subject: [PATCH 3/4] firmware: google: memconsole: Use const 'struct bin_attribute' callback 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: <20241215-sysfs-const-bin_attr-google-v1-3-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=1259; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=GPoO2MlSyFN41keL/IQMHVzwngO96d3fyeoIVD73xh0=; b=Rj/FM7RcVBGvm/gpxe+tx2rQ8WNOo+HWXEO2lIlSCw+4yndXGxNqd5yMUrbhhDpFa6SHj113J OUzVm/WZIkxAnOxLJaqIotYuRPnqD/evAmeLx2kACKW6uwd42u+0gul X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The sysfs core now provides callback variants that explicitly take a const pointer. Use them so the non-const variants can be removed. Signed-off-by: Thomas Wei=C3=9Fschuh Acked-by: Brian Norris --- drivers/firmware/google/memconsole.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google= /memconsole.c index b9d99fe1ff0f683f9fff3c4bc669d2a85c703366..d957af6f934984b74627e83f458= 575dbf2b7d592 100644 --- a/drivers/firmware/google/memconsole.c +++ b/drivers/firmware/google/memconsole.c @@ -14,7 +14,7 @@ #include "memconsole.h" =20 static ssize_t memconsole_read(struct file *filp, struct kobject *kobp, - struct bin_attribute *bin_attr, char *buf, + const struct bin_attribute *bin_attr, char *buf, loff_t pos, size_t count) { ssize_t (*memconsole_read_func)(char *, loff_t, size_t); @@ -28,7 +28,7 @@ static ssize_t memconsole_read(struct file *filp, struct = kobject *kobp, =20 static struct bin_attribute memconsole_bin_attr =3D { .attr =3D {.name =3D "log", .mode =3D 0444}, - .read =3D memconsole_read, + .read_new =3D memconsole_read, }; =20 void memconsole_setup(ssize_t (*read_func)(char *, loff_t, size_t)) --=20 2.47.1 From nobody Wed Dec 17 18:01:15 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 7AA2018E050 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=qGDEBit4YVE9TId4ZeSuH+MrDAIdnn9ms50vBZEWnMYfCmDF3WywJa/rRvT1YBIbK1QZoT9uQQRDsp2zBQbBf92OBI0I3vsMuDXtntZMxJCFp9Gky4q2bXKUGZ1/ODLbN0YXnaZ2CHQfhgJpiT2E7zmzEdhLA2xQoO9yrcMJR0s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734274159; c=relaxed/simple; bh=WLLl0SXp2QxmvD1/OoHCr/gA5uXOCZ9Y2YGLQhVDl4s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aiGeAAiDEDorStgnmOdt8y0Yq/eTtRgRPd9v6mZMPn9Xsv54YjWMHVsHkwZtnXsDx4fGRhBlmPWPhN4cxwxIh5uZli6sejKXAWN0p5st3x1Pu4WWAoqHq5fp9JnGMq2OmiYuSQEodMyY4f90ELejjAcNRcWwGiGAXMOnraha7bY= 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=dS6BGN6d; 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="dS6BGN6d" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734274154; bh=WLLl0SXp2QxmvD1/OoHCr/gA5uXOCZ9Y2YGLQhVDl4s=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=dS6BGN6d3DlsD5DTIEYhmwPuix1uiCp8OSaRbOgXHat0v9chIV4ZFUfz/jEfsM04B S1SVKDnAenBUee1bZ3nk59i5IqGo4TB9gtMMrfoZ+b+ZdptUKvbFbo0mDOTdKdAJCU gO4ShP8n5Hbpf+EnKAHiNoIiAoYsCtFks49DGQCQ= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 15 Dec 2024 15:49:12 +0100 Subject: [PATCH 4/4] firmware: google: vpd: Use const 'struct bin_attribute' callback 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: <20241215-sysfs-const-bin_attr-google-v1-4-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=3481; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=WLLl0SXp2QxmvD1/OoHCr/gA5uXOCZ9Y2YGLQhVDl4s=; b=JnFxNi5bWLzCfBERDYtH86MY5DNmcQ9bY8COJI+GLalpI7cZQmFWf8FjrDl03KEuxUiLc4uvT TWrSRh5uiYbD/QL8mUOJOJz09vNs03PnzF70MIFJvYM3gcyWao/j7Ri X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The sysfs core now provides callback variants that explicitly take a const pointer. Use them so the non-const variants can be removed. Signed-off-by: Thomas Wei=C3=9Fschuh Acked-by: Brian Norris --- The custom read functions could also just be replaced by sysfs_bin_attr_simple_read(). See below. That would slightly conflict with another series of mine [0], bute the resolution would be trivial. [0] https://lore.kernel.org/lkml/20241205-sysfs-const-bin_attr-simple-v1-0-= 4a4e4ced71e3@weissschuh.net/ diff --git a/drivers/firmware/google/vpd.c b/drivers/firmware/google/vpd.c index 254ac6545d68..1ce9a7af635e 100644 --- a/drivers/firmware/google/vpd.c +++ b/drivers/firmware/google/vpd.c @@ -121,8 +111,8 @@ static int vpd_section_attrib_add(const u8 *key, u32 k= ey_len, info->bin_attr.attr.name =3D info->key; info->bin_attr.attr.mode =3D 0444; info->bin_attr.size =3D value_len; - info->bin_attr.read_new =3D vpd_attrib_read; - info->bin_attr.private =3D info; + info->bin_attr.read =3D sysfs_bin_attr_simple_read; + info->bin_attr.private =3D (void *)info->value; info->value =3D value; static int vpd_section_create_attribs(struct vpd_section *sec) { s32 consumed; @@ -201,8 +181,8 @@ static int vpd_section_init(const char *name, struct v= pd_section *sec, sec->bin_attr.attr.name =3D sec->raw_name; sec->bin_attr.attr.mode =3D 0444; sec->bin_attr.size =3D size; - sec->bin_attr.read_new =3D vpd_section_read; - sec->bin_attr.private =3D sec; + sec->bin_attr.read =3D sysfs_bin_attr_simple_read; + sec->bin_attr.private =3D sec->baseaddr; err =3D sysfs_create_bin_file(vpd_kobj, &sec->bin_attr); if (err) --- drivers/firmware/google/vpd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/google/vpd.c b/drivers/firmware/google/vpd.c index 1749529f63d449dd88e90e12ac6e50ad8f15450d..254ac6545d680ac099ae2efa3c2= 109c9eb8c41be 100644 --- a/drivers/firmware/google/vpd.c +++ b/drivers/firmware/google/vpd.c @@ -56,7 +56,7 @@ static struct vpd_section ro_vpd; static struct vpd_section rw_vpd; =20 static ssize_t vpd_attrib_read(struct file *filp, struct kobject *kobp, - struct bin_attribute *bin_attr, char *buf, + const struct bin_attribute *bin_attr, char *buf, loff_t pos, size_t count) { struct vpd_attrib_info *info =3D bin_attr->private; @@ -121,7 +121,7 @@ static int vpd_section_attrib_add(const u8 *key, u32 ke= y_len, info->bin_attr.attr.name =3D info->key; info->bin_attr.attr.mode =3D 0444; info->bin_attr.size =3D value_len; - info->bin_attr.read =3D vpd_attrib_read; + info->bin_attr.read_new =3D vpd_attrib_read; info->bin_attr.private =3D info; =20 info->value =3D value; @@ -156,7 +156,7 @@ static void vpd_section_attrib_destroy(struct vpd_secti= on *sec) } =20 static ssize_t vpd_section_read(struct file *filp, struct kobject *kobp, - struct bin_attribute *bin_attr, char *buf, + const struct bin_attribute *bin_attr, char *buf, loff_t pos, size_t count) { struct vpd_section *sec =3D bin_attr->private; @@ -201,7 +201,7 @@ static int vpd_section_init(const char *name, struct vp= d_section *sec, sec->bin_attr.attr.name =3D sec->raw_name; sec->bin_attr.attr.mode =3D 0444; sec->bin_attr.size =3D size; - sec->bin_attr.read =3D vpd_section_read; + sec->bin_attr.read_new =3D vpd_section_read; sec->bin_attr.private =3D sec; =20 err =3D sysfs_create_bin_file(vpd_kobj, &sec->bin_attr); --=20 2.47.1