From nobody Tue Aug 25 16:00:38 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 4hTsvC16Slz6pbgr for ; Tue, 25 Aug 2026 16:00:39 +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 4hTsvB63Qfz43BC for ; Tue, 25 Aug 2026 16:00:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1787673638; 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=5j6/gTv82CAnp/vT9pmRjNKw4O6C2Gq1Gb7DQ6NILKo=; b=Y3utXUC+qMEtgB5Y99X9ZmYpgILlF6+Ghs39+dp+DPclgPoyfjASQ+xTHDdHJBz8YBGZnK f/gC4PbKIbc4Ysrs3hLSkpm4nPrTy/EkBzTJQ1gZ8bscGG9RFtJLtFzukM5+Uj34WyDm3P rcpYEaOdpICQH1qMGgd0pUuuexThQ/lEKp6enPXoywawb8R3SGpGS5Sp9l/kCeQoqDsI4K ogd2OSz+gP4v/tfW0LRJq+k/EE8/F1T1DHzuYnAcgeSuXyjUKmqA53srE19KswqCO9KBM/ BP1DXA0z+8VLZA0B1hRgy5gPtQ29h0BkYXG1N44uAZn/mlbxcjSGTUm/CAnzmg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1787673638; a=rsa-sha256; cv=none; b=XnNp156Xr5WWVD2b7RHwfpLWAdxXTM3OUfahk7IwFniznU0og1Nh8uhUf/jkS6eedUWWFC Bih7Hv9dneVmCERclsoFfN/nFGkB8fHbhp5MyOcKCS2AzMmAP7i/lt862oTszGvBdiNkJA Jng12N5W8+POTats4jD5/7zjs0d7rHpeLQ/qhTKtfCmY22RgnhRmaP/6THdKvoPPXWZ1as fA5PqxTx1KI83/VnfX4zUmuSf2nh1ztLALKAbW2E2g7gz3T5xvIgXCE7ULpRAvfX5XEnvr TEY5b86M9lOdkPNnEvt4mjA4/m805ePslFdGNMeCUJtyXc2E/OSF2NhDi3DsSg== 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=1787673638; 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=5j6/gTv82CAnp/vT9pmRjNKw4O6C2Gq1Gb7DQ6NILKo=; b=sxVTp2oFtD4/hS2xuh+nUdHrwT8qvx14udf79mdy6KzHgUvPuL1x1SfGYeZXOwG1HmBpYX XLCpwR/koi6T+Cw3UfFb1vGNlxTajYxJvix3oYmNt52M0ktyEpAsX44tqmUWKpPn45V/yV GrnvauumcYdP5RFoglcgg6/zogxvgWGeHTxVKOZl+h+dT4yAdyr+3w3qC+lVbMRwIvfTQz TuWf6RW0Z++H9wU+H2weQlVxShzY+ZtvtLKmfbmYMX8K9sQUbcokzIWQ5lPNN8DvSZO6ol PDIyuXL+oLyi/N2CGqys+qFe8oye8zLAe1iF6rxv0juJjlLQax/EeCEWLhYpJA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hTsvB4yFHzxZW for ; Tue, 25 Aug 2026 16:00:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 336f0 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 25 Aug 2026 16:00:38 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 514ef2fdfc9b - releng/14.5 - 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/14.5 X-Git-Reftype: branch X-Git-Commit: 514ef2fdfc9b5195184c4ef689255a63c6a288e1 Auto-Submitted: auto-generated Date: Tue, 25 Aug 2026 16:00:38 +0000 Message-Id: <6a8dbc26.336f0.2457ced5@gitrepo.freebsd.org> The branch releng/14.5 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=514ef2fdfc9b5195184c4ef689255a63c6a288e1 commit 514ef2fdfc9b5195184c4ef689255a63c6a288e1 Author: Mark Johnston AuthorDate: 2026-08-24 15:20:32 +0000 Commit: Mark Johnston CommitDate: 2026-08-24 19:03:06 +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: re (cperciva) 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 9ad21d219001..059dc23993cd 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 4d69f176225c..96cd794c1fed 100644 --- a/sys/dev/sound/pcm/dsp.c +++ b/sys/dev/sound/pcm/dsp.c @@ -2720,14 +2720,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) { @@ -2764,16 +2761,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) {