* [PATCH] ALSA: pcm: Avoid reading beyond ELD monitor name
@ 2026-11-20 12:46 Sreeraj S Kurup
2026-11-20 17:11 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Sreeraj S Kurup @ 2026-11-20 12:46 UTC (permalink / raw)
To: perex, tiwai; +Cc: linux-kernel, linux-sound, Sreeraj S Kurup
snd_parse_eld() checks that mnl bytes are available in the ELD
buffer, but passes mnl + 1 as the source size to strscpy().
When the monitor name is not NUL-terminated and the buffer ends
immediately after the mnl bytes, strscpy() may read beyond the
provided buffer.
Copy exactly mnl bytes and explicitly terminate the destination
to avoid accessing a byte beyond the validated input length.
Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
---
sound/core/pcm_drm_eld.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/sound/core/pcm_drm_eld.c b/sound/core/pcm_drm_eld.c
index 1941ee520063..556e5a43710d 100644
--- a/sound/core/pcm_drm_eld.c
+++ b/sound/core/pcm_drm_eld.c
@@ -362,8 +362,10 @@ int snd_parse_eld(struct device *dev, struct snd_parsed_hdmi_eld *e,
} else if (ELD_FIXED_BYTES + mnl > size) {
dev_info(dev, "HDMI: out of range MNL %d\n", mnl);
goto out_fail;
- } else
- strscpy(e->monitor_name, buf + ELD_FIXED_BYTES, mnl + 1);
+ } else {
+ memcpy(e->monitor_name, buf + ELD_FIXED_BYTES, mnl);
+ e->monitor_name[mnl] = '\0';
+ }
for (i = 0; i < e->sad_count; i++) {
if (ELD_FIXED_BYTES + mnl + 3 * (i + 1) > size) {
--
2.55.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ALSA: pcm: Avoid reading beyond ELD monitor name
2026-11-20 12:46 [PATCH] ALSA: pcm: Avoid reading beyond ELD monitor name Sreeraj S Kurup
@ 2026-11-20 17:11 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-11-20 17:11 UTC (permalink / raw)
To: Sreeraj S Kurup; +Cc: perex, tiwai, linux-kernel, linux-sound
On Fri, 20 Nov 2026 13:46:07 +0100,
Sreeraj S Kurup wrote:
>
> snd_parse_eld() checks that mnl bytes are available in the ELD
> buffer, but passes mnl + 1 as the source size to strscpy().
>
> When the monitor name is not NUL-terminated and the buffer ends
> immediately after the mnl bytes, strscpy() may read beyond the
> provided buffer.
>
> Copy exactly mnl bytes and explicitly terminate the destination
> to avoid accessing a byte beyond the validated input length.
>
> Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
Applied to for-next branch. Thanks.
Takashi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-20 17:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 12:46 [PATCH] ALSA: pcm: Avoid reading beyond ELD monitor name Sreeraj S Kurup
2026-11-20 17:11 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox