From nobody Tue Aug 25 16:01:23 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 4hTsw35wCRz6pbtG for ; Tue, 25 Aug 2026 16:01:23 +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 4hTsw33VyVz44Xk for ; Tue, 25 Aug 2026 16:01:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1787673683; 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=nuLe7LBZI6Ok2nje35i9gKIGMpjIJwMs8/8rrvoxQf0=; b=xUEbA9/NSdThepNEgeRKUjvUfAAxaMvQ4uAp2joIzCmISkxrGcX6SggZS8I4QpF5hkp9tv bRIovZyIzoMA8M4NIHpO5lqVpETFe+/KFKyI22MxRAv/d/BxjutTLeDrCCQvLI75oGspDv ezH0ASvz1+b+qRzGjkDoaROf1pG3e1oUC7V8IuTQoIVePi0AIT5f+EXgADQpAH+b7raRDk iFvJHnAMsqm+UlD9KqgrNdZ1EEJZfEdfunCkxzDckMT5T/Ict1QHMZpQzBbP5QsfynQ6M1 8jPzWSKQQ6CxhL5XClbep7jXAYK4S9nDKxR0pJD0KJmpnmwksxfTEyfTI3L8uw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1787673683; a=rsa-sha256; cv=none; b=QqosUk35R3ext0K+xYr/R0+FL23rd3YDv9+7t0SyIGNUhfM6ehnLkFUdfkU6sHcVLpxRkv ryoVmNrAS/lrGVW8wPAQawWCLsazHlOjRh2FoPBLAcXRR5dEMwBv1UX1Gs193Qt3xNsiZR ug24KhWTahTiZ4LRSeyM6q0gw+1JMomcARs5kIANDc/ki4VoJOWH9PGHknmikIqT7tLKw9 mbx89ICujfRGdP9hdf/9t0l4ox1LuO1TmgKSvIxkC9YGg60pacL/24mxUSh1PPBDAzc8W1 c+A0LtVwleJ4d1Ts1DISn6Wb5hPaKb3hiht8r6fpeAyzjlY7yH97ntCVZBqxOA== 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=1787673683; 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=nuLe7LBZI6Ok2nje35i9gKIGMpjIJwMs8/8rrvoxQf0=; b=LJuJoUJ3MJ4Yn/3qN/mugVk5rjiIsz8A+hJnf4a0qhOSTXW71gj72QFIV9qVEgnm+Sz/uh NGLmEEnG+UN2Vie6kzh4JYD9KwQSJhKDpvI3hYx0lMZZUq8GW6/quKRL915Q/eV84SXjmG LhLQ90I/VPaHD3hB+0VBenjB1NbwxCCWSbpBKqQazT4ZPfacfQy9vJF7GQYjBZPpqdtMtd HxGpBl+Y1++toRt39IPiBJ+gOD5yCzpLjI1MWnGHI8ErFA0kjhxdqOk5t9kJ0gAPfaCRFk /a/Tr2AMTbg1II5q+IheN7H28otW+c0QFdZuKI1UJ+qeFEEVTetyEbBZ36vN+Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hTsw32QGdzxsb for ; Tue, 25 Aug 2026 16:01:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 331d0 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 25 Aug 2026 16:01:23 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 48c25324ff1c - releng/15.1 - 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/releng/15.1 X-Git-Reftype: branch X-Git-Commit: 48c25324ff1cd2aeb1cb691ce6c907ecb4612c46 Auto-Submitted: auto-generated Date: Tue, 25 Aug 2026 16:01:23 +0000 Message-Id: <6a8dbc53.331d0.4a00d8e7@gitrepo.freebsd.org> The branch releng/15.1 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=48c25324ff1cd2aeb1cb691ce6c907ecb4612c46 commit 48c25324ff1cd2aeb1cb691ce6c907ecb4612c46 Author: Mark Johnston AuthorDate: 2026-08-24 15:20:32 +0000 Commit: Mark Johnston CommitDate: 2026-08-24 19:34:13 +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 6fa4338dce4a..563eed70aaba 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 147779ca9d1d..eb8992a766b5 100644 --- a/sys/dev/sound/pcm/dsp.c +++ b/sys/dev/sound/pcm/dsp.c @@ -2696,14 +2696,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) { @@ -2740,16 +2737,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) {