* [PATCH] ALSA: seq: Serialize compat port-info ioctls
@ 2026-09-17 10:56 Bruno Produit
2026-09-17 12:36 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Bruno Produit @ 2026-09-17 10:56 UTC (permalink / raw)
To: Jaroslav Kysela, Takashi Iwai
Cc: Kyle Zeng, linux-sound, linux-kernel, Dominik Czarnota, stable,
Bruno Produit
From: Kyle Zeng <kylebot@openai.com>
The native sequencer ioctl path serializes handler calls with
client->ioctl_mutex, but the translated port-info compat path invokes the
same handlers through snd_seq_kernel_client_ctl() without taking that
mutex.
This lets concurrent compat CREATE_PORT requests pass the port-count
check before any request reaches the serialized insertion. The computed
integer port index can then exceed the address field range and wrap to an
existing index. Subsequent subscriber teardown can resolve the duplicate
address to the wrong port and access a freed subscriber.
Take ioctl_mutex while dispatching converted port-info requests, matching
the native ioctl path. All translated port-info commands share this
helper, so their accesses to the client port state are serialized as
well.
Fixes: b3defb791b26 ("ALSA: seq: Make ioctls race-free")
Cc: stable@vger.kernel.org
Assisted-by: Codex:gpt-5.6-sol gpt-6-astra
Signed-off-by: Kyle Zeng <kylebot@openai.com>
Signed-off-by: Bruno Produit <bruno.produit@trailofbits.com>
---
Trail of Bits has a reproducer for this bug that triggers a
KASAN use-after-free and can it share if needed
sound/core/seq/seq_compat.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sound/core/seq/seq_compat.c b/sound/core/seq/seq_compat.c
index 22679dca9..80110501d 100644
--- a/sound/core/seq/seq_compat.c
+++ b/sound/core/seq/seq_compat.c
@@ -44,7 +44,9 @@ static int snd_seq_call_port_info_ioctl(struct snd_seq_client *client, unsigned
return -EFAULT;
data->kernel = NULL;
- err = snd_seq_kernel_client_ctl(client->number, cmd, data);
+ scoped_guard(mutex, &client->ioctl_mutex) {
+ err = snd_seq_kernel_client_ctl(client->number, cmd, data);
+ }
if (err < 0)
return err;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] ALSA: seq: Serialize compat port-info ioctls
2026-09-17 10:56 [PATCH] ALSA: seq: Serialize compat port-info ioctls Bruno Produit
@ 2026-09-17 12:36 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-09-17 12:36 UTC (permalink / raw)
To: Bruno Produit
Cc: Jaroslav Kysela, Takashi Iwai, Kyle Zeng, linux-sound,
linux-kernel, Dominik Czarnota, stable
On Thu, 17 Sep 2026 12:56:43 +0200,
Bruno Produit wrote:
>
> From: Kyle Zeng <kylebot@openai.com>
>
> The native sequencer ioctl path serializes handler calls with
> client->ioctl_mutex, but the translated port-info compat path invokes the
> same handlers through snd_seq_kernel_client_ctl() without taking that
> mutex.
>
> This lets concurrent compat CREATE_PORT requests pass the port-count
> check before any request reaches the serialized insertion. The computed
> integer port index can then exceed the address field range and wrap to an
> existing index. Subsequent subscriber teardown can resolve the duplicate
> address to the wrong port and access a freed subscriber.
>
> Take ioctl_mutex while dispatching converted port-info requests, matching
> the native ioctl path. All translated port-info commands share this
> helper, so their accesses to the client port state are serialized as
> well.
>
> Fixes: b3defb791b26 ("ALSA: seq: Make ioctls race-free")
> Cc: stable@vger.kernel.org
> Assisted-by: Codex:gpt-5.6-sol gpt-6-astra
> Signed-off-by: Kyle Zeng <kylebot@openai.com>
> Signed-off-by: Bruno Produit <bruno.produit@trailofbits.com>
> ---
>
> Trail of Bits has a reproducer for this bug that triggers a
> KASAN use-after-free and can it share if needed
The bug looks obvious, a long-standing oversight.
Applied now.
thanks,
Takashi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-17 12:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-17 10:56 [PATCH] ALSA: seq: Serialize compat port-info ioctls Bruno Produit
2026-09-17 12:36 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®