drm/debugfs: Accept "reset" with a trailing newline in edid_override
Subsystems (2)
PATCH v2 1/1 drm/debugfs: Accept "reset" with a trailing newline in edid_override
Writing "reset" to edid_override only removes the override when exactly those five bytes are written, so "echo reset > edid_override" fails with -EINVAL and leaves the override in place.
Compare with sysfs_streq() on a NUL-terminated copy, and reject writes larger than the largest possible EDID (256 blocks) before copying, so that the size of the copy is bounded.
---
Tested on an Orange Pi 5 (RK3588S) with this patch on a 7.3 based
kernel: "echo reset" and "printf reset" both remove an override, an EDID override round trip still works, and garbage or oversized writes fail with -EINVAL.
Developed with Claude (Anthropic), which wrote the code and the commit
message. I reviewed and tested it.
---
Changes in v2:
- Use memdup_user_nul() and sysfs_streq() (Jani Nikula)
- Reject writes larger than 256 EDID blocks before copying
- Shorter commit message
- Link to v1: https://patch.msgid.link/[email protected]
--- drivers/gpu/drm/drm_debugfs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_debugfs.c +6 -2
@@ -565,11 +565,15 @@ static ssize_t edid_write(struct file *file, const char __user *ubuf,char *buf;int ret; - buf =memdup_user (ubuf, len); +/* An EDID has at most 256 blocks */ +if (len >256 *EDID_LENGTH ) +return -EINVAL ; + + buf =memdup_user_nul (ubuf, len);if (IS_ERR (buf))return PTR_ERR (buf); -if (len ==5 && !strncmp (buf,"reset" ,5 )) +if (sysfs_streq (buf,"reset" )) ret =drm_edid_override_reset (connector);else ret =drm_edid_override_set (connector, buf, len);
---
base-commit: cb0a63f0c96e8ecb90199eeb99cc2a7fcfa703d4
change-id: 20261110-drm-debugfs-edid-reset-0504a20c67d1
Best regards,
Signature · 1 line
Arun Iyengar <[email protected]>
Quoted 35 lines · On Fri, 13 Nov 2026, Arun Iyengar via B4 Relay…
From: Arun Iyengar <[email protected]>
Writing "reset" to
edid_overrideonly removes the override when exactly those five bytes are written, so "echo reset >edid_override" fails with-EINVALand leaves the override in place.Compare with
sysfs_streq()on a NUL-terminated copy, and reject writes larger than the largest possible EDID (256 blocks) before copying, so that the size of the copy is bounded.Suggested-by Jani Nikula <[email protected]>Signed-off-by Arun Iyengar <[email protected]>---
Tested on an Orange Pi 5 (RK3588S) with this patch on a 7.3 based
kernel: "echo reset" and "printf reset" both remove an override, an EDID override round trip still works, and garbage or oversized writes fail with-EINVAL.Developed with Claude (Anthropic), which wrote the code and the commit
message. I reviewed and tested it.
---
Changes in v2:
- Usememdup_user_nul()andsysfs_streq()(Jani Nikula)
- Reject writes larger than 256 EDID blocks before copying
- Shorter commit message
- Link to v1: https://patch.msgid.link/[email protected]--- drivers/gpu/drm/drm_debugfs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/gpu/drm/drm_debugfs.c +0
-0
drivers/gpu/drm/drm_debugfs.c static ssize_t edid_write(struct file *file, const char __user *ubuf, · line 570
Quoted 7 lines
drivers/gpu/drm/drm_debugfs.c +3
-1@@ -565,11 +565,15 @@ static ssize_t edid_write(struct file *file, const char __user *ubuf,char *buf;int ret; - buf =memdup_user (ubuf, len); +/* An EDID has at most 256 blocks */ +if (len >256 *EDID_LENGTH ) +return -EINVAL ;
This is an unrelated change nobody asked for, and it diverges from a review I tried to converge by presenting a clean hand-written solution that the LLM didn't come up with on its own.
BR,
Jani.
Quoted 20 lines
drivers/gpu/drm/drm_debugfs.c +3
-2+ + buf =memdup_user_nul (ubuf, len);if (IS_ERR (buf))return PTR_ERR (buf); -if (len ==5 && !strncmp (buf,"reset" ,5 )) +if (sysfs_streq (buf,"reset" )) ret =drm_edid_override_reset (connector);else ret =drm_edid_override_set (connector, buf, len); ---base-commit:
cb0a63f0c96e8ecb90199eeb99cc2a7fcfa703d4
change-id: 20261110-drm-debugfs-edid-reset-0504a20c67d1Best regards,
Signature · 1 line
Arun Iyengar <[email protected]>
Signature · 1 line
Jani Nikula, Intel