From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796386057; b=PhL4K6ikDuyZIbsYh16YwdSCIysXRXwJD/5o/YHnd2QQGvKDJ0UT3USjWgDVanA8HO24 n63DgtDKmenz6Op50zOwAr0J5WQmXDxWo343bitskzcYDjjD0lihD07FFmVvxa0H+Pnig gr4QaEz+MgtAJl8UvLyJ1sWzxvQ9iL8/WpvveEDnBgVtg9Y23vaROhAZQbCcVdF/jfUuC cpZs4FyQAbYhcltzPi4WfIy3R6EQ04L8mRGryG44kqYlvwhihaaaVSQUn8ZMLwkym1KHN nUHqEvkBGSJp4cabM8HiH53NHkkZ0qzorv5+MX51iB9AAUaEF/9+g+EaIe76X3r1jew== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386057; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=oqJdqJSmIDoImmOW80OsW4Rz+jJisxCd0UfBTHKt/ZA=; b=yfzlLxtlsvU6E3tuSVkdDWXqpMAJ8YiZesMhw+2uC2Q29Tl6L+PO2I7BSjHGmjk0bBHZ Y9DUNfOwWfXs/U6uPkWmWSsJ7ER/r1mNrctgdtm+cvMPzLo72uCbggG8VfIHDdDc04ASy +SfSQU7N5whpH/imDg0DFm975XoEXClZp6/pbQ+WtGJBCw7Q9YrJNfOo4/Zjmv9thQFuv QBHGCPeN0+794M4pdcSlLTQQVspqsjfTrmGqjeRSDgn6y1qAVFaXDX/kJiMtglyKPMrzR uKeVng/4gYaPtS9Gdrc1n1PBPRTXP/IPtRGrBk0yAxu3HGxN4cFrMKZX3qYLLub66WA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=10H5zUwy; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E7146606A322; Fri, 4 Dec 2026 12:07:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=10H5zUwy Received: by smtp.kernel.org (Postfix) with ESMTPSA id 616281F000CE; Fri, 4 Dec 2026 12:07:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796386056; bh=oqJdqJSmIDoImmOW80OsW4Rz+jJisxCd0UfBTHKt/ZA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=10H5zUwy61qQUe7WzS8GKLDSuYDZjkfm4flxBeGueDMyywTdM165SfdNtC70aAPp3 WlbLeniTF9geZBkdXE7tt60w7Mp/QqVrzcjGMdLzz2b4DlbKV80j21d1OqGqkaf1Jw /6QLqquug0LSynfNjBLHqVtha1ELOB9g/0HRNvKw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, HyeongJun An , Takashi Iwai , Sasha Levin Subject: [PATCH 6.6 0767/1167] ALSA: seq: Dont leak the extension cell pointer in the bounce payload Date: Fri, 4 Dec 2026 19:03:14 +0900 Message-ID: <20261204100722.067449472@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: HyeongJun An [ Upstream commit 59e1592d3c270ff4642d5d6dc55c545306eb0693 ] The bounce_error_event() embeds the failed event in the bounce payload by pointing data.ext.ptr at it. When that event is a queued variable-length event, its own data.ext.ptr holds the address of its first extension cell, put there by snd_seq_event_dup(). The payload goes out verbatim through snd_seq_expand_var_event(), so the address reaches userspace. That is the same address commit 705dd6dcbc0e ("ALSA: seq: Clear variable event pointer on read") removed from the event header. The read path still clears it there, just above the call that expands the payload. Embed a sanitised copy instead, treated exactly as snd_seq_read() treats the header. A stack copy is enough because delivery is synchronous and snd_seq_event_dup() copies before returning. An unprivileged client reaches this by setting SNDRV_SEQ_FILTER_BOUNCE, queueing a variable-length event to a port that does not exist and reading the bounce back. Eight bytes on 64-bit, from its own pool. Fixes: efc86691e4d8 ("ALSA: seq: Fix kernel heap address leak in bounce_error_event()") Assisted-by: Claude:claude-opus-5 Signed-off-by: HyeongJun An Link: https://patch.msgid.link/20260811131835.3837024-1-sammiee5311@gmail.com Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/core/seq/seq_clientmgr.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index f039fd6ee3a74..de17b66cd16b3 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c @@ -578,7 +578,7 @@ static int bounce_error_event(struct snd_seq_client *client, struct snd_seq_event *event, int err, int atomic, int hop) { - struct snd_seq_event bounce_ev; + struct snd_seq_event bounce_ev, quoted; int result; if (client == NULL || @@ -594,15 +594,19 @@ static int bounce_error_event(struct snd_seq_client *client, * For user clients, send SNDRV_SEQ_EVENT_BOUNCE with the * original event embedded as variable-length data. This * avoids exposing data.quote.event (a kernel pointer) to - * userspace. The variable-length path in snd_seq_event_dup() - * copies the event data from data.ext.ptr into chained cells, - * and snd_seq_expand_var_event() copies only the data content - * -- never the pointer -- to userspace. + * userspace. Sanitise the embedded copy too - a queued + * variable-length event carries the address of its own + * extension cell, and the payload goes out verbatim. */ + quoted = *event; + if (snd_seq_ev_is_variable("ed)) { + quoted.data.ext.len &= ~SNDRV_SEQ_EXT_MASK; + quoted.data.ext.ptr = NULL; + } bounce_ev.type = SNDRV_SEQ_EVENT_BOUNCE; bounce_ev.flags = SNDRV_SEQ_EVENT_LENGTH_VARIABLE; bounce_ev.data.ext.len = sizeof(struct snd_seq_event); - bounce_ev.data.ext.ptr = (char *)event; + bounce_ev.data.ext.ptr = (char *)"ed; } else { /* * For kernel clients, quote the event pointer directly. -- 2.53.0