From nobody Wed Dec 17 19:52:39 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 5E152200121 for ; Mon, 16 Dec 2024 11:34:52 +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=1734348894; cv=none; b=thFP7cDdVohwnggTRK23EmcuLiUYH9NiUFLW8BbN1A+nCuvuVVTEW5xrS70GSzBamc2b0+yow+12JEiyc6dXDcwr0QGyNtyd1GJTmzsnqrFeXT9tsIY5EhwtWfL8bZqOY5jh59qdhWcI9wSrpX93k/2/aWoR8nCFTPt3ifAftfc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734348894; c=relaxed/simple; bh=o2oExs9IS06W2wuTSfy7oT1l8YCPWwQFt6kUrnFUcG0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FJeoCBZmeUvNxlVmYDpiTIvxHFEa64IGctLKgecrAA8US/wHfrY8k5j/Ad6HZdxLzgi6YQ95bWgBtC5DBJL+VAtIpN6v8gljMWRzpd/NOay878fkwcXaaTeW6/SxobEd/1x2Dt60StypyFMn9BazZN2LJQ6CPcjhiAOYu1ASzPM= 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=TFLqVQXc; 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="TFLqVQXc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734348890; bh=o2oExs9IS06W2wuTSfy7oT1l8YCPWwQFt6kUrnFUcG0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=TFLqVQXcetsLZl4BIY3y/1jcvzpCNw4sozes71NWxTpoeXNFd/FcaFvjWwhhLY2rF hUl5+AoaGI+/nwWzjIXSRKwa+gGP/K2UyCwgd9Q9ApO0Bm8tNO0LfO8HVKZ0Er4HqL Z3no+vu54umlGSikUT99/vtxnbiDss237I0jhFyY= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 16 Dec 2024 12:34:47 +0100 Subject: [PATCH 1/5] drm/sysfs: 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: <20241216-sysfs-const-bin_attr-drm-v1-1-210f2b36b9bf@weissschuh.net> References: <20241216-sysfs-const-bin_attr-drm-v1-0-210f2b36b9bf@weissschuh.net> In-Reply-To: <20241216-sysfs-const-bin_attr-drm-v1-0-210f2b36b9bf@weissschuh.net> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Qiang Yu , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xinhui Pan , Harry Wentland , Leo Li , Rodrigo Siqueira Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, lima@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734348889; l=1644; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=o2oExs9IS06W2wuTSfy7oT1l8YCPWwQFt6kUrnFUcG0=; b=YDmkkKVCgYlLLAJGaraFPnhIxIZeJCB5izojwBThggOwU+itKqHGgNedKgKWJkRPTYsHnYk+P abbCqn4jFHpBwSskuQY+JEl64etJ1fYoE5IJrYarbj6F/tbjMPeoIJF 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 Reviewed-by: Andi Shyti Reviewed-by: Jani Nikula --- drivers/gpu/drm/drm_sysfs.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c index fb3bbb6adcd16f3f325a2ae8e35f41851c00b272..60c1f26edb6fad23153c32a29fd= 3be02700fc938 100644 --- a/drivers/gpu/drm/drm_sysfs.c +++ b/drivers/gpu/drm/drm_sysfs.c @@ -261,7 +261,7 @@ static ssize_t enabled_show(struct device *device, } =20 static ssize_t edid_show(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, char *buf, loff_t off, + const struct bin_attribute *attr, char *buf, loff_t off, size_t count) { struct device *connector_dev =3D kobj_to_dev(kobj); @@ -315,21 +315,21 @@ static struct attribute *connector_dev_attrs[] =3D { NULL }; =20 -static struct bin_attribute edid_attr =3D { +static const struct bin_attribute edid_attr =3D { .attr.name =3D "edid", .attr.mode =3D 0444, .size =3D 0, - .read =3D edid_show, + .read_new =3D edid_show, }; =20 -static struct bin_attribute *connector_bin_attrs[] =3D { +static const struct bin_attribute *const connector_bin_attrs[] =3D { &edid_attr, NULL }; =20 static const struct attribute_group connector_dev_group =3D { .attrs =3D connector_dev_attrs, - .bin_attrs =3D connector_bin_attrs, + .bin_attrs_new =3D connector_bin_attrs, }; =20 static const struct attribute_group *connector_dev_groups[] =3D { --=20 2.47.1 From nobody Wed Dec 17 19:52:39 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 D31BF203D77 for ; Mon, 16 Dec 2024 11:34:52 +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=1734348895; cv=none; b=TF/dmO08ARd2Gj4pdrKNL38UXga1r91qu/kLIWD0wpBAgjcq2emOHmrJ4M0ouyz67OSMbRV8F0SCDJpJUCApjZmtZcM2Ygv4HajMUMsvDwnNrBKjy259A0epdfIWpNoKsW24/BLdbVMIKjsR55the6A36n7h5TgtDOY3um/TpyE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734348895; c=relaxed/simple; bh=1qtbMa2oIpffo9qrfeElmnz139mrppvwu3zsjT10qrM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BPkS4Uk6AidJZSqJx2xcOy7L5NGsWgEJ04ObrJY+cUT9WsCv8AKOt0iC+262DDMUNM6829DtsbKG9ZwOFgRHZnFQEDM9bRKa8cpiL1qTrl/T1878GUd3kxYUWc5JvRo8ozz6TGO3/3JijWEzkeZY1VLBZ4J9tVrlc+W3hCLjDR0= 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=N5W6GuU5; 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="N5W6GuU5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734348890; bh=1qtbMa2oIpffo9qrfeElmnz139mrppvwu3zsjT10qrM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=N5W6GuU506HNT67hwXsBzcHmTOnA3z9T530lNzo6ZAFFjhK4OuxHW/hT28vPUXRUe HxFFqadWxwc4SPCpP6eFLmSoFTcMlA8bB15EBXUpbmR7cdcRtfIUouR+vVKt9Uw2e0 Rea2lK1bB6x6zC30dJQ1M2KZpt3Bi2wn3c2giG7g= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 16 Dec 2024 12:34:48 +0100 Subject: [PATCH 2/5] drm/lima: 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: <20241216-sysfs-const-bin_attr-drm-v1-2-210f2b36b9bf@weissschuh.net> References: <20241216-sysfs-const-bin_attr-drm-v1-0-210f2b36b9bf@weissschuh.net> In-Reply-To: <20241216-sysfs-const-bin_attr-drm-v1-0-210f2b36b9bf@weissschuh.net> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Qiang Yu , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xinhui Pan , Harry Wentland , Leo Li , Rodrigo Siqueira Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, lima@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734348889; l=1710; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=1qtbMa2oIpffo9qrfeElmnz139mrppvwu3zsjT10qrM=; b=1WNI1ZkIE8rqLbERLmmdHNShe5o5cZbun/mqENhN73fwlitBkkCVqnSWtvKibM9ZtYm50iZQz jn1nSK2Tek2Du1yWr9Wxx1x0jCnSs6GepiyTnnI7BHf93+3qRL9WWgz 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 Reviewed-by: Andi Shyti --- drivers/gpu/drm/lima/lima_drv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/lima/lima_drv.c b/drivers/gpu/drm/lima/lima_dr= v.c index fb3062c872b317ef27cd321b2638944f8a5dc33a..b969bd3f28968304946c0bb6294= 60e91622d5fbc 100644 --- a/drivers/gpu/drm/lima/lima_drv.c +++ b/drivers/gpu/drm/lima/lima_drv.c @@ -311,7 +311,7 @@ static bool lima_read_block(struct lima_block_reader *r= eader, } =20 static ssize_t lima_error_state_read(struct file *filp, struct kobject *ko= bj, - struct bin_attribute *attr, char *buf, + const struct bin_attribute *attr, char *buf, loff_t off, size_t count) { struct device *dev =3D kobj_to_dev(kobj); @@ -337,7 +337,7 @@ static ssize_t lima_error_state_read(struct file *filp,= struct kobject *kobj, } =20 static ssize_t lima_error_state_write(struct file *file, struct kobject *k= obj, - struct bin_attribute *attr, char *buf, + const struct bin_attribute *attr, char *buf, loff_t off, size_t count) { struct device *dev =3D kobj_to_dev(kobj); @@ -363,8 +363,8 @@ static const struct bin_attribute lima_error_state_attr= =3D { .attr.name =3D "error", .attr.mode =3D 0600, .size =3D 0, - .read =3D lima_error_state_read, - .write =3D lima_error_state_write, + .read_new =3D lima_error_state_read, + .write_new =3D lima_error_state_write, }; =20 static int lima_pdev_probe(struct platform_device *pdev) --=20 2.47.1 From nobody Wed Dec 17 19:52:39 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 3B3B5204599 for ; Mon, 16 Dec 2024 11:34:53 +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=1734348894; cv=none; b=TByvbjig6YSfzsjhvLruh7H1RKSCj9UtxdM+xcaEVtCm+icXBbgpo1BUu0xzuLfoHnV2yBX3PQ30gphbNuolRS8IaNUMagFmon6H6dh92Ul8fMRttKs/WHyeSpYoF38thH4sP0+voVxxCHqIjggH2lPFBVpwZ8yKlYoJZCHbkdo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734348894; c=relaxed/simple; bh=UcFNLmnvsYaQOHcmZvcmxzeMoweYVAEm2PgsTyadgkI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Dxxmco0mJmK9d7B5WsnQe91ckTzMQMXHf5vGxOMqqSUedoEJ8D6oPEsi7yPy6g7TGo+71qwxsxDZJrfth6pKnE2T/DbGljT2jZE/BUqhiKvFszbumU5B++iwrJYPsG8kbZR4ptbnCr1AtgR+8gP23ot9C8uqms8ct+Xoc7MwUIY= 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=syJzmf0d; 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="syJzmf0d" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734348890; bh=UcFNLmnvsYaQOHcmZvcmxzeMoweYVAEm2PgsTyadgkI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=syJzmf0d4MfCocdBz4SdwRhaTCrA7uJxy2KQkCR7vFDUozn+OrKnjr+sCP5846KEM pOb1SZsB+JL7/uyO0moALDM8wWobbJx88Pq57EmLv/sD7CAT4zYI681gHjAcS6phLE 1xB6vfUEiLUnjkBkMiiTLyZs6ozj1ORaZReYlWv0= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 16 Dec 2024 12:34:49 +0100 Subject: [PATCH 3/5] drm/i915: 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: <20241216-sysfs-const-bin_attr-drm-v1-3-210f2b36b9bf@weissschuh.net> References: <20241216-sysfs-const-bin_attr-drm-v1-0-210f2b36b9bf@weissschuh.net> In-Reply-To: <20241216-sysfs-const-bin_attr-drm-v1-0-210f2b36b9bf@weissschuh.net> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Qiang Yu , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xinhui Pan , Harry Wentland , Leo Li , Rodrigo Siqueira Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, lima@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734348889; l=3431; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=UcFNLmnvsYaQOHcmZvcmxzeMoweYVAEm2PgsTyadgkI=; b=Cf8bG3lKy+H2AAGHpNlU9pJX+g0endqvP6W/4Y7M0B1o4fSNb6WQQ2Ir7gmA0kMgrqUn11+go eYMtY4tn9ibBNp7Y4fsPYQsbC+bjLvJlQU2xTEStr9ySkNZJezQ0n2x 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 Reviewed-by: Andi Shyti Reviewed-by: Jani Nikula --- drivers/gpu/drm/i915/i915_gpu_error.c | 8 ++++---- drivers/gpu/drm/i915/i915_sysfs.c | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i= 915_gpu_error.c index 71c0daef19962660086b37fe55ca2d6b01f2bb9a..a4cb4e731bdd72201c91541fb86= e827e96214a8b 100644 --- a/drivers/gpu/drm/i915/i915_gpu_error.c +++ b/drivers/gpu/drm/i915/i915_gpu_error.c @@ -2491,7 +2491,7 @@ void i915_gpu_error_debugfs_register(struct drm_i915_= private *i915) } =20 static ssize_t error_state_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, char *buf, + const struct bin_attribute *attr, char *buf, loff_t off, size_t count) { =20 @@ -2527,7 +2527,7 @@ static ssize_t error_state_read(struct file *filp, st= ruct kobject *kobj, } =20 static ssize_t error_state_write(struct file *file, struct kobject *kobj, - struct bin_attribute *attr, char *buf, + const struct bin_attribute *attr, char *buf, loff_t off, size_t count) { struct device *kdev =3D kobj_to_dev(kobj); @@ -2543,8 +2543,8 @@ static const struct bin_attribute error_state_attr = =3D { .attr.name =3D "error", .attr.mode =3D S_IRUSR | S_IWUSR, .size =3D 0, - .read =3D error_state_read, - .write =3D error_state_write, + .read_new =3D error_state_read, + .write_new =3D error_state_write, }; =20 void i915_gpu_error_sysfs_setup(struct drm_i915_private *i915) diff --git a/drivers/gpu/drm/i915/i915_sysfs.c b/drivers/gpu/drm/i915/i915_= sysfs.c index 8775beab9cb8438c2e8abb0f9d8104dcba7c0df3..f936e8f1f12942287a5a7d6aa7d= b6ed3a4c28281 100644 --- a/drivers/gpu/drm/i915/i915_sysfs.c +++ b/drivers/gpu/drm/i915/i915_sysfs.c @@ -60,7 +60,7 @@ static int l3_access_valid(struct drm_i915_private *i915,= loff_t offset) =20 static ssize_t i915_l3_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, char *buf, + const struct bin_attribute *attr, char *buf, loff_t offset, size_t count) { struct device *kdev =3D kobj_to_dev(kobj); @@ -88,7 +88,7 @@ i915_l3_read(struct file *filp, struct kobject *kobj, =20 static ssize_t i915_l3_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, char *buf, + const struct bin_attribute *attr, char *buf, loff_t offset, size_t count) { struct device *kdev =3D kobj_to_dev(kobj); @@ -140,8 +140,8 @@ i915_l3_write(struct file *filp, struct kobject *kobj, static const struct bin_attribute dpf_attrs =3D { .attr =3D {.name =3D "l3_parity", .mode =3D (S_IRUSR | S_IWUSR)}, .size =3D GEN7_L3LOG_SIZE, - .read =3D i915_l3_read, - .write =3D i915_l3_write, + .read_new =3D i915_l3_read, + .write_new =3D i915_l3_write, .mmap =3D NULL, .private =3D (void *)0 }; @@ -149,8 +149,8 @@ static const struct bin_attribute dpf_attrs =3D { static const struct bin_attribute dpf_attrs_1 =3D { .attr =3D {.name =3D "l3_parity_slice_1", .mode =3D (S_IRUSR | S_IWUSR)}, .size =3D GEN7_L3LOG_SIZE, - .read =3D i915_l3_read, - .write =3D i915_l3_write, + .read_new =3D i915_l3_read, + .write_new =3D i915_l3_write, .mmap =3D NULL, .private =3D (void *)1 }; --=20 2.47.1 From nobody Wed Dec 17 19:52:39 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 0188F204568 for ; Mon, 16 Dec 2024 11:34:52 +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=1734348894; cv=none; b=NvxYCOs/5k4GoztfvxvAebC399tCKkZ0hLfjAEMcNN6c7ftIfhF0qpRmMCSdUe5p/aclal9RaTJx18CaS7CPMzjVAirwNQ6EMTTGSvOe5+4ijKYRLB1TVUP9Xe3arT0xMIjDTilAwK17ZFS/JnO7aKNWhJ8lc30bMJvPZ85Mm/E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734348894; c=relaxed/simple; bh=zuT+LJN8yyZdjBUYgx4LeWWwlVkL7wdTwqvya297jls=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=a0CpWKl79PMSu/RvOm+RdhaAiaS/fqFE3U8E/1brX4Ie8OtqlsTMDQAaeLLhdLn4cP94VCkKIUrRasBf8519H330ziwO5PMseSV4ikuc5UcRC4qneENDNgN7OZmMvNt153leh97IF8NErg/Rt62IEZbFmLaKS6Uo9P8vMnKJwC8= 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=Q8zsUSw4; 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="Q8zsUSw4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734348890; bh=zuT+LJN8yyZdjBUYgx4LeWWwlVkL7wdTwqvya297jls=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Q8zsUSw45BtgARRdWi3boy4K+6THyxtcF4oUO/jPWdN8pAVOI3rQJkUz2GF14htdS EJ2du0p7474uP0KSCM97/l/z1co3lKUSAc74rJf5fgoR6CzcZ1LWTHAsGnO8OtsJ4V Ns1bKYa8fvFqN9jvTm/aHo3VwdBTsiFTm1imSxpw= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 16 Dec 2024 12:34:50 +0100 Subject: [PATCH 4/5] drm/amdgpu: 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: <20241216-sysfs-const-bin_attr-drm-v1-4-210f2b36b9bf@weissschuh.net> References: <20241216-sysfs-const-bin_attr-drm-v1-0-210f2b36b9bf@weissschuh.net> In-Reply-To: <20241216-sysfs-const-bin_attr-drm-v1-0-210f2b36b9bf@weissschuh.net> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Qiang Yu , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xinhui Pan , Harry Wentland , Leo Li , Rodrigo Siqueira Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, lima@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734348889; l=5717; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=zuT+LJN8yyZdjBUYgx4LeWWwlVkL7wdTwqvya297jls=; b=t/e4NpjzaihOxUQhxM9fCFKwdSbBN4HpYBXnVQDcuR8p8/tYTm7wlNTElz/kh4GFe2sa+7MPl RfSBcyst2hbDjIWe0ng8erI2054SsD6gVbtFvLfTdtHkotBHapZ8aeM 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 Reviewed-by: Alex Deucher --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +++--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 14 +++++++------- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 13 ++++++------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/a= md/amdgpu/amdgpu_device.c index d272d95dd5b2f5eb83be279281d55af323f7f508..88459de2cd2e47390d33e593987= 5c3322b740b4d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -223,7 +223,7 @@ static DEVICE_ATTR(pcie_replay_count, 0444, amdgpu_device_get_pcie_replay_count, NULL); =20 static ssize_t amdgpu_sysfs_reg_state_get(struct file *f, struct kobject *= kobj, - struct bin_attribute *attr, char *buf, + const struct bin_attribute *attr, char *buf, loff_t ppos, size_t count) { struct device *dev =3D kobj_to_dev(kobj); @@ -259,8 +259,8 @@ static ssize_t amdgpu_sysfs_reg_state_get(struct file *= f, struct kobject *kobj, return bytes_read; } =20 -BIN_ATTR(reg_state, 0444, amdgpu_sysfs_reg_state_get, NULL, - AMDGPU_SYS_REG_STATE_END); +static const BIN_ATTR(reg_state, 0444, amdgpu_sysfs_reg_state_get, NULL, + AMDGPU_SYS_REG_STATE_END); =20 int amdgpu_reg_state_sysfs_init(struct amdgpu_device *adev) { diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/= amdgpu/amdgpu_psp.c index 448f9e742983f3ef0c5fccc18d85f0c2449aa08e..cda25174730a6852bcb6e01aeec= 858faad172b19 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c @@ -3969,7 +3969,7 @@ int is_psp_fw_valid(struct psp_bin_desc bin) } =20 static ssize_t amdgpu_psp_vbflash_write(struct file *filp, struct kobject = *kobj, - struct bin_attribute *bin_attr, + const struct bin_attribute *bin_attr, char *buffer, loff_t pos, size_t count) { struct device *dev =3D kobj_to_dev(kobj); @@ -4005,7 +4005,7 @@ static ssize_t amdgpu_psp_vbflash_write(struct file *= filp, struct kobject *kobj, } =20 static ssize_t amdgpu_psp_vbflash_read(struct file *filp, struct kobject *= kobj, - struct bin_attribute *bin_attr, char *buffer, + const struct bin_attribute *bin_attr, char *buffer, loff_t pos, size_t count) { struct device *dev =3D kobj_to_dev(kobj); @@ -4057,11 +4057,11 @@ static ssize_t amdgpu_psp_vbflash_read(struct file = *filp, struct kobject *kobj, * Writing to this file will stage an IFWI for update. Reading from this f= ile * will trigger the update process. */ -static struct bin_attribute psp_vbflash_bin_attr =3D { +static const struct bin_attribute psp_vbflash_bin_attr =3D { .attr =3D {.name =3D "psp_vbflash", .mode =3D 0660}, .size =3D 0, - .write =3D amdgpu_psp_vbflash_write, - .read =3D amdgpu_psp_vbflash_read, + .write_new =3D amdgpu_psp_vbflash_write, + .read_new =3D amdgpu_psp_vbflash_read, }; =20 /** @@ -4088,7 +4088,7 @@ static ssize_t amdgpu_psp_vbflash_status(struct devic= e *dev, } static DEVICE_ATTR(psp_vbflash_status, 0440, amdgpu_psp_vbflash_status, NU= LL); =20 -static struct bin_attribute *bin_flash_attrs[] =3D { +static const struct bin_attribute *const bin_flash_attrs[] =3D { &psp_vbflash_bin_attr, NULL }; @@ -4124,7 +4124,7 @@ static umode_t amdgpu_bin_flash_attr_is_visible(struc= t kobject *kobj, =20 const struct attribute_group amdgpu_flash_attr_group =3D { .attrs =3D flash_attrs, - .bin_attrs =3D bin_flash_attrs, + .bin_attrs_new =3D bin_flash_attrs, .is_bin_visible =3D amdgpu_bin_flash_attr_is_visible, .is_visible =3D amdgpu_flash_attr_is_visible, }; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/= amdgpu/amdgpu_ras.c index 4c9fa24dd9726a405935907524ed7bf7862779d1..2991e0967b5bfc848328aaa59dd= fb9a8f202bae9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c @@ -1732,7 +1732,7 @@ static char *amdgpu_ras_badpage_flags_str(unsigned in= t flags) */ =20 static ssize_t amdgpu_ras_sysfs_badpages_read(struct file *f, - struct kobject *kobj, struct bin_attribute *attr, + struct kobject *kobj, const struct bin_attribute *attr, char *buf, loff_t ppos, size_t count) { struct amdgpu_ras *con =3D @@ -2063,8 +2063,8 @@ void amdgpu_ras_debugfs_create_all(struct amdgpu_devi= ce *adev) /* debugfs end */ =20 /* ras fs */ -static BIN_ATTR(gpu_vram_bad_pages, S_IRUGO, - amdgpu_ras_sysfs_badpages_read, NULL, 0); +static const BIN_ATTR(gpu_vram_bad_pages, S_IRUGO, + amdgpu_ras_sysfs_badpages_read, NULL, 0); static DEVICE_ATTR(features, S_IRUGO, amdgpu_ras_sysfs_features_read, NULL); static DEVICE_ATTR(version, 0444, @@ -2086,7 +2086,7 @@ static int amdgpu_ras_fs_init(struct amdgpu_device *a= dev) &con->event_state_attr.attr, NULL }; - struct bin_attribute *bin_attrs[] =3D { + const struct bin_attribute *bin_attrs[] =3D { NULL, NULL, }; @@ -2112,11 +2112,10 @@ static int amdgpu_ras_fs_init(struct amdgpu_device = *adev) =20 if (amdgpu_bad_page_threshold !=3D 0) { /* add bad_page_features entry */ - bin_attr_gpu_vram_bad_pages.private =3D NULL; con->badpages_attr =3D bin_attr_gpu_vram_bad_pages; + sysfs_bin_attr_init(&con->badpages_attr); bin_attrs[0] =3D &con->badpages_attr; - group.bin_attrs =3D bin_attrs; - sysfs_bin_attr_init(bin_attrs[0]); + group.bin_attrs_new =3D bin_attrs; } =20 r =3D sysfs_create_group(&adev->dev->kobj, &group); --=20 2.47.1 From nobody Wed Dec 17 19:52:39 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 3436A2066E9 for ; Mon, 16 Dec 2024 11:34:55 +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=1734348897; cv=none; b=DjHAKOXWM1kI926wiRx8TGGufSq45Ra0Y1Aq6slXPqGAoJaT6I+IpQS7X6AUTqza1xYffOUAwWrmkqcqUrxjTdS0TxuIjODKQHf4ytHPpkpNU6za9oriXUDHxqVt/e1aejSBNxCxMULMeaJIVzrrHTbcMSEDUIJgzjrYnyL9Xig= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734348897; c=relaxed/simple; bh=y5VdIlFmZrN99wi17sHDS/2XA6J1JYaGxHyZF4VUIi4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EcAvRbhXVFS7hkgWEWxh8t/H//U1lRrbQImcl3UHTjbOLYgS/MXAj5KzGNhu3CnKXMLWMnIrySu2BQ5qAmZnX6lWDhc7Rl9mBobVW94vvEqVkdc0PnLKYAgoWeDFd7fDy5O61sAa9HJDGUIGhxfm0mEkfO9UAAYLHqp8L5nB8gg= 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=I1LoHCoq; 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="I1LoHCoq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734348890; bh=y5VdIlFmZrN99wi17sHDS/2XA6J1JYaGxHyZF4VUIi4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=I1LoHCoq945+zGqi2IJw4PxdFgsNnMEsCh+MDvewdAwWOrbvQ6KLSiNTIbLg5yzn1 jcN/lq3bd/ulKW8+VJAlilAJWJHswSCyZg3KwsVTXZlMx816S/1SrZ9k6QbcliP1NA lz2vqXg8r3nA+XBY8L+mzkSccVgIdg/yYTKDS9KM= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 16 Dec 2024 12:34:51 +0100 Subject: [PATCH 5/5] drm/amd/display: 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: <20241216-sysfs-const-bin_attr-drm-v1-5-210f2b36b9bf@weissschuh.net> References: <20241216-sysfs-const-bin_attr-drm-v1-0-210f2b36b9bf@weissschuh.net> In-Reply-To: <20241216-sysfs-const-bin_attr-drm-v1-0-210f2b36b9bf@weissschuh.net> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Qiang Yu , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xinhui Pan , Harry Wentland , Leo Li , Rodrigo Siqueira Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, lima@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734348889; l=1989; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=y5VdIlFmZrN99wi17sHDS/2XA6J1JYaGxHyZF4VUIi4=; b=CINJ3HLrSMhMcfUsU7NZIyH1+y1/TzIm0rkb5ETIxXa+H/f3F/O5bIuXKhuLkCFAOgO1NyygM 0FozzyXfHeLAjv++M4Tndb+I24Twp4TVweWBj+rGRLNhapMZs6RYICv 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 Reviewed-by: Harry Wentland --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c b/drive= rs/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c index e339c7a8d541c962aa44ae25ad97b864285394b8..e27d077396327bbe25014aec5b9= 78293b1c20dac 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c @@ -614,7 +614,7 @@ static void update_config(void *handle, struct cp_psp_s= tream_config *config) * incorrect/corrupted and we should correct our SRM by getting it from PSP */ static ssize_t srm_data_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buffer, + const struct bin_attribute *bin_attr, char *buffer, loff_t pos, size_t count) { struct hdcp_workqueue *work; @@ -638,7 +638,7 @@ static ssize_t srm_data_write(struct file *filp, struct= kobject *kobj, } =20 static ssize_t srm_data_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buffer, + const struct bin_attribute *bin_attr, char *buffer, loff_t pos, size_t count) { struct hdcp_workqueue *work; @@ -698,8 +698,8 @@ static ssize_t srm_data_read(struct file *filp, struct = kobject *kobj, static const struct bin_attribute data_attr =3D { .attr =3D {.name =3D "hdcp_srm", .mode =3D 0664}, .size =3D PSP_HDCP_SRM_FIRST_GEN_MAX_SIZE, /* Limit SRM size */ - .write =3D srm_data_write, - .read =3D srm_data_read, + .write_new =3D srm_data_write, + .read_new =3D srm_data_read, }; =20 struct hdcp_workqueue *hdcp_create_workqueue(struct amdgpu_device *adev, --=20 2.47.1