From nobody Tue Aug 25 15:59:48 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4hTstF6byvz6pbXp for ; Tue, 25 Aug 2026 15:59:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hTstF2CVQz41wT for ; Tue, 25 Aug 2026 15:59:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1787673589; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Q1rO3hrTBfj83smeGsKi3M+XZUL6LelVdUDVSpsQ+dE=; b=OxEOPglgIOLQuDK2O7rpmgOFoSNpe7paTqgiC3alF8WZzVRc3oUkXuD4PH/zE1U9IrnsvJ fAfrgfGmidyUVEjO2+SA/Ak0cLfSLY3GAC1S4LzIwB/fTQbmEbWzMP1g/7Rw1zNcje6IHR y5pya+wmwuWSVoBer+9Wl9rGpTsNF6LtkDYXX6PK+Txctpe1lFymrZDco5y4TXE1G2ivJn +GopDemjFeCGH+tshfAWxPGYGGjDzXE4bLWTL8qkF0V58KfPnyN4lqFjoLQ02yPrL9RotG 50lW/uBOrERZtSZbp8MLi2BTvrSBbNGe6PTP0Y1Z1NqdOj+0MmwOf0IWos6HGA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1787673589; a=rsa-sha256; cv=none; b=RrLXagAznc5+oyLm0Gt+j0hQzwSNlz86xDFnCJlm/qPU5+PlDDfV01v332jfpkhgWyROkJ jQUuews+xq4xj0/Wjc6GeGDShUNgUFnlcXB3ZILjNVgxlnbN0eqT2I2sRH6+QYpd8duYCK yY0shLDqIVQ7i2k62yhQqWICwLFsn0TgVKqQ0+PtYtAe3e2qrc14bHUaH8So7pJiMQIrlm uQMD/X/sORV0O++bxfp/+yKGu9x3Dj9SBi0gMdd1lFgTP65H4IkxTtJjNQjJ7R2rwHRt4U LXLtw8BEfEEI+jGaptSihFt6k3J1D1Izctk3LgXlgp8keyDpAv13Lczwt9BYfA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1787673589; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Q1rO3hrTBfj83smeGsKi3M+XZUL6LelVdUDVSpsQ+dE=; b=Y8t1RXBoGT8vIegGF+7mUIHLjppx4mi3W57XDOkdTsV8+JoM1FnCaafY2/GkKPPHqJYT2n 5oX5tneXjwPth2tsbsy7RWY7ePidIHkgKegRkKsE53YwOAQHCYH9ycEY/PAn7FtVeHa/cv CYfgj3n6eYWWvIlPfFBNUIR7Nu22SB8O+36WDED4T8a/ZKd6ninmuqExSUxNzdlYm9OJKQ GEZI6c3qkV+47W84oo4WQQlkutk7CeVaix3DOQwo9xjIfQzALvE+MkkYKt7VhJIGo2E42E QsPnGgCZoP8wZqC9FURQQlxweQYK3uYx4jQ8EVHUKrZOT33vS2L3Z97NjTJPKw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hTstD666rzxs2 for ; Tue, 25 Aug 2026 15:59:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 32170 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 25 Aug 2026 15:59:48 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: edff72e5f64c - stable/15 - dsp: Fix a potential use-after-free in dsp_oss_syncstart() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: edff72e5f64cc04ae41a9da6336d0ec7779e48df Auto-Submitted: auto-generated Date: Tue, 25 Aug 2026 15:59:48 +0000 Message-Id: <6a8dbbf4.32170.514623be@gitrepo.freebsd.org> The branch stable/15 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=edff72e5f64cc04ae41a9da6336d0ec7779e48df commit edff72e5f64cc04ae41a9da6336d0ec7779e48df Author: Mark Johnston AuthorDate: 2026-08-24 15:20:32 +0000 Commit: Mark Johnston CommitDate: 2026-08-25 15:47:12 +0000 dsp: Fix a potential use-after-free in dsp_oss_syncstart() This function has a loop where it attempts to lock all channels in a group. If doing so would block, it releases all locks, sleeps for a bit, and tries again. However, once the syncgroup lock is dropped, nothing prevents the syncgroup structure from being freed. Fix the inner loop: after waking up, break out of it unconditionally and start everything again. I think the old code was also buggy and not well-exercised: after waking up we'd continue to try and continue locking channels. Then we'd try again from the beginning and fail to lock the channels we had already locked. Approved by: so Security: FreeBSD-SA-26:58.sound Security: CVE-2026-58091 Reported by: Hazley Samsudin of GovTech CSG Reviewed by: christos Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D58912 --- sys/dev/sound/pcm/channel.h | 9 +++++---- sys/dev/sound/pcm/dsp.c | 17 ++++++----------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/sys/dev/sound/pcm/channel.h b/sys/dev/sound/pcm/channel.h index aac6ab368625..2f71f0708c8e 100644 --- a/sys/dev/sound/pcm/channel.h +++ b/sys/dev/sound/pcm/channel.h @@ -57,10 +57,11 @@ struct pcmchan_syncmember; extern struct mtx snd_pcm_syncgroups_mtx; extern SLIST_HEAD(pcm_synclist, pcmchan_syncgroup) snd_pcm_syncgroups; -#define PCM_SG_LOCK() mtx_lock(&snd_pcm_syncgroups_mtx) -#define PCM_SG_TRYLOCK() mtx_trylock(&snd_pcm_syncgroups_mtx) -#define PCM_SG_UNLOCK() mtx_unlock(&snd_pcm_syncgroups_mtx) -#define PCM_SG_LOCKASSERT(arg) mtx_assert(&snd_pcm_syncgroups_mtx, arg) +#define PCM_SG_LOCKPTR() (&snd_pcm_syncgroups_mtx) +#define PCM_SG_LOCK() mtx_lock(PCM_SG_LOCKPTR()) +#define PCM_SG_TRYLOCK() mtx_trylock(PCM_SG_LOCKPTR()) +#define PCM_SG_UNLOCK() mtx_unlock(PCM_SG_LOCKPTR()) +#define PCM_SG_LOCKASSERT(arg) mtx_assert(PCM_SG_LOCKPTR(), arg) /** * @brief Specifies an audio device sync group diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c index 8952447a705a..633f096a4e78 100644 --- a/sys/dev/sound/pcm/dsp.c +++ b/sys/dev/sound/pcm/dsp.c @@ -2684,14 +2684,11 @@ dsp_oss_syncstart(int sg_id) struct pcmchan_syncmember *sm, *sm_tmp; struct pcmchan_syncgroup *sg; struct pcm_channel *c; - int ret, needlocks; + int ret; - /* Get the synclists lock */ PCM_SG_LOCK(); - do { ret = 0; - needlocks = 0; /* Search for syncgroup by ID */ SLIST_FOREACH(sg, &snd_pcm_syncgroups, link) { @@ -2728,16 +2725,14 @@ dsp_oss_syncstart(int sg_id) } /** @todo Is PRIBIO correct/ */ - ret = msleep(sm, &snd_pcm_syncgroups_mtx, + ret = msleep(sm, PCM_SG_LOCKPTR(), PRIBIO | PCATCH, "pcmsg", timo); - if (ret == EINTR || ret == ERESTART) - break; - - needlocks = 1; - ret = 0; /* Assumes ret == EAGAIN... */ + if (ret == EAGAIN) + ret = 0; + break; } } - } while (needlocks && ret == 0); + } while (ret == 0 && sm != NULL); /* Proceed only if no errors encountered. */ if (ret == 0) {