| From 705dd6dcbc0ea87351c660c1a6443f85f1001c76 Mon Sep 17 00:00:00 2001 |
| From: Kyle Zeng <kylebot@openai.com> |
| Date: Sat, 6 Jun 2026 17:41:29 -0700 |
| Subject: ALSA: seq: Clear variable event pointer on read |
| |
| From: Kyle Zeng <kylebot@openai.com> |
| |
| commit 705dd6dcbc0ea87351c660c1a6443f85f1001c76 upstream. |
| |
| snd_seq_read() copies a queued variable-length event header to userspace |
| before expanding the payload. Queued variable-length events use |
| SNDRV_SEQ_EXT_CHAINED internally, and data.ext.ptr points at the first |
| extension cell. |
| |
| The read side strips SNDRV_SEQ_EXT_* bits from data.ext.len before the |
| copy, but it leaves data.ext.ptr untouched. A userspace sequencer client |
| can therefore write a direct variable event to itself and read back the |
| extension-cell kernel address from the returned header. |
| |
| Clear the temporary header pointer before copy_to_user(). The original |
| queued event remains unchanged and is still passed to |
| snd_seq_expand_var_event(), so payload expansion keeps using the |
| internal chain. |
| |
| Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") |
| Signed-off-by: Kyle Zeng <kylebot@openai.com> |
| Link: https://patch.msgid.link/20260607004129.61345-1-kylebot@openai.com |
| Signed-off-by: Takashi Iwai <tiwai@suse.de> |
| Signed-off-by: Roman Demidov <roman.demidov.nn@gmail.com> |
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
| --- |
| sound/core/seq/seq_clientmgr.c | 1 + |
| 1 file changed, 1 insertion(+) |
| |
| --- a/sound/core/seq/seq_clientmgr.c |
| +++ b/sound/core/seq/seq_clientmgr.c |
| @@ -441,6 +441,7 @@ static ssize_t snd_seq_read(struct file |
| struct snd_seq_event tmpev; |
| tmpev = cell->event; |
| tmpev.data.ext.len &= ~SNDRV_SEQ_EXT_MASK; |
| + tmpev.data.ext.ptr = NULL; |
| if (copy_to_user(buf, &tmpev, sizeof(struct snd_seq_event))) { |
| err = -EFAULT; |
| break; |