From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A161374E60; Sat, 17 Oct 2026 17:20:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792257620; cv=none; b=fPk+tf+DhFdTtD2JrmCWABKlQNx3vwBSMoYpm13CU1H3mZQOLm3z5hGrE1PBXg1yzjDcrtKaoAr19KbB6Dghso/mSr6pxkteMXSzM1+tttMR6mq2o7eSIKgJ/IpxTfTtPfRr2IesrtOoJnm+4UkfJkX0+Jinb7oMvG8RACMp4Cw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792257620; c=relaxed/simple; bh=GZMKvpMZ36yq4c4TAgR3cTeUV6XJm/76qP/+jyp3/ns=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RTdwDDfkvqtb00kvgngLJqrE0heunxHm/tHjS24ovr2ZHb7SF1ItbHwqEXfTF+mu4WVth/gJdK4Eo7KUUGksEP/aK5ALNZWXHzTqt/jmtUwKvUrj7ljaDgfm1ohsOBMCUaqJPIobamVrm5OuI5og/qj8AJfrXs/KU3Lzq3QKO78= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=0QrNPxnc; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="0QrNPxnc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4A451F000C4; Sat, 17 Oct 2026 17:20:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1792257619; bh=px7xKM7F/B9B/5WzB+LVGItQS9OBG42eALYhrn8jKxM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=0QrNPxncik8+G0VY/jNqCzfP1I3yua8xVVeLaRwcCPVjwqB4UsA0XklcwMi5yYE1t ahHOnzOzATlYnyg/EoijoqU4wYxZ9/qI/hKq+Lopz8JcCx7f2eXlWy44k2E9UQn8DF HK8dNlV/IEEU/vTSoqdeWX6EkYn38FrMEehANAFo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+8e498074a794999eb41c@syzkaller.appspotmail.com, =?UTF-8?q?C=C3=A1ssio=20Gabriel?= , Takashi Iwai , Artem Dinaburg , Sasha Levin Subject: [PATCH 6.6 0575/1674] ALSA: pcm: oss: Fix setup list UAF on proc write error Date: Sat, 17 Oct 2026 17:47:27 +0200 Message-ID: <20261017160445.852609865@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261017160431.119607952@linuxfoundation.org> References: <20261017160431.119607952@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cássio Gabriel [ Upstream commit 4cc54bdd54b337e77115be5b55577d1c58608eae ] snd_pcm_oss_proc_write() links a newly allocated setup entry into the OSS setup list before duplicating the task name. If the task-name allocation fails, the error path frees the already linked entry and leaves setup_list pointing at freed memory. A later OSS device open can then walk the stale list entry in snd_pcm_oss_look_for_setup() and dereference freed memory. Allocate the task name and initialize the setup entry before publishing the entry on setup_list. Also fetch the initial proc read iterator only after taking setup_mutex, so all setup_list traversal follows the same list lifetime rules. Reported-by: syzbot+8e498074a794999eb41c@syzkaller.appspotmail.com Closes: https://lore.kernel.org/all/6a1062b7.170a0220.35b2b7.0003.GAE@google.com Closes: https://syzkaller.appspot.com/bug?extid=8e498074a794999eb41c Fixes: 060d77b9c04a ("[ALSA] Fix / clean up PCM-OSS setup hooks") Signed-off-by: Cássio Gabriel Link: https://patch.msgid.link/20260522-alsa-pcm-oss-setup-uaf-v1-1-40bdcc4d17e8@gmail.com Signed-off-by: Takashi Iwai Assisted-by: LLM [ Backport to 6.6.y: Keep the target's explicit setup_mutex unlocks on allocation failure and before continuing; upstream releases that mutex through its scoped guard. ] Signed-off-by: Artem Dinaburg Signed-off-by: Sasha Levin --- sound/core/oss/pcm_oss.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index 23ecbd70ccf65..25f7e585bc7b9 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c @@ -2964,8 +2964,10 @@ static void snd_pcm_oss_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { struct snd_pcm_str *pstr = entry->private_data; - struct snd_pcm_oss_setup *setup = pstr->oss.setup_list; + struct snd_pcm_oss_setup *setup; + mutex_lock(&pstr->oss.setup_mutex); + setup = pstr->oss.setup_list; while (setup) { snd_iprintf(buffer, "%s %u %u%s%s%s%s%s%s\n", setup->task_name, @@ -3053,6 +3055,14 @@ static void snd_pcm_oss_proc_write(struct snd_info_entry *entry, mutex_unlock(&pstr->oss.setup_mutex); return; } + template.task_name = kstrdup(task_name, GFP_KERNEL); + if (!template.task_name) { + kfree(setup); + buffer->error = -ENOMEM; + mutex_unlock(&pstr->oss.setup_mutex); + return; + } + *setup = template; if (pstr->oss.setup_list == NULL) pstr->oss.setup_list = setup; else { @@ -3060,13 +3070,8 @@ static void snd_pcm_oss_proc_write(struct snd_info_entry *entry, setup1->next; setup1 = setup1->next); setup1->next = setup; } - template.task_name = kstrdup(task_name, GFP_KERNEL); - if (! template.task_name) { - kfree(setup); - buffer->error = -ENOMEM; - mutex_unlock(&pstr->oss.setup_mutex); - return; - } + mutex_unlock(&pstr->oss.setup_mutex); + continue; } *setup = template; mutex_unlock(&pstr->oss.setup_mutex); -- 2.53.0