From nobody Tue Nov 17 17:01:55 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 4jTWH84Nctz71Q1d for ; Tue, 17 Nov 2026 17:01:56 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jTWH80Y8Rz3Q2l for ; Tue, 17 Nov 2026 17:01:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794934916; 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=KCjKQ4Kymjh4SK+KLavwD3pxnpVoMIdl5V8/sdPfS4A=; b=AO+FTwR8mEydVB6m5H3Y4vPl3FLTQiRedMaM7ds+BpSIxmong/Ib16dZuICXrka4b3Wyn8 MgR3JJOWZCTFIZwkMm6z0qiyUWMP0+qJkWHBDam/lECfO6ftwyqhjTEFgDZnGw7lpSwY0B F+UV3DnBDpgaL1qCMVrnHmkKRA3QYLvIVYfwwxJUnPBbyRP3XgTF9iIvoiUuGvBM+oVXLK 92GOfjnF8dHRM7Hw5mz21aUpPmrBo9HtkTbuSeBy9O0Zdk243Q7HW0lZ6Vt/xQ5++2WRPl D3bG8iygZBHuzF24AmvDWuwBSDctXg+ZMlzkECe5vAzYSlirl3IxSKzICoVrWQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794934916; b=uVwjMqoRNHUGAQ1phG7vd2d2913MF/k3IIlE5SE2VdEHPpj1U/L78GM8DjrpoiSHDbqyjZ 9XTC2gtvdrEOCyC9SKXp/yPsUgX2VxgcG1r/LxrCBdCwzGtK6vKSSifsZEeyPZgl0KgIcy 7U6mejI5uLj1tjro6/Qf00GHlKGS0JiLbc0C+JXwK8ZYDRpl59ClaQ6Sq33yiqM+eWUQUf L3FSGGjGH8qtrMaqxKpxeSJyJ49FVShE4XMICLvorwaBJTE/iZ9ADaPo2DbzYeCgPHcEn+ k1vrL+7UJgOJJB58hDTZulrr0AcaSTCqe2fXEIoUq5bSetcPvUNrGfGbFQqpKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794934916; 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=KCjKQ4Kymjh4SK+KLavwD3pxnpVoMIdl5V8/sdPfS4A=; b=oVJKCeaBJ7Ek8YJ8reXAOBc6xBuNDLL0+MESMLroVrakU0v3PbE3IAoxWpGzq/vcXY8v6h FfyIoov1fu8c0Q8x4K9HB9IunVcTeDeIk3x84U5BseK6bHPbZEMlKcgns+VlG1yKLqUcav sFD+s5cfXWb/xj0Mrlig4mHdO8bCBkDd0FIghB21jqe+Uuvw1dilTOIyt+z5kizSVOqiLF tTtExHuLKTjqDNU254P+pjUXJvJjiYJ0IB4zO2MNB9Utx+H75e+1+xGR8UPx92OPDiilf4 7+JTVtvMk1KR+VtDFWQ/kwFXXhYTPAO0rLt4pQITe7Gr9jBj5+m0mEUr5jR6Ow== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jTWH773j8zrR8 for ; Tue, 17 Nov 2026 17:01:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1e90b by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 17 Nov 2026 17:01:55 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: de2e72575fe2 - main - sound: Improve interlocking in chn_resizebuf() List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository 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/main X-Git-Reftype: branch X-Git-Commit: de2e72575fe2ea314285511c2039347c8214c056 Auto-Submitted: auto-generated Date: Tue, 17 Nov 2026 17:01:55 +0000 Message-Id: <6afc8883.1e90b.6b6fc7f4@gitrepo.freebsd.org> The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=de2e72575fe2ea314285511c2039347c8214c056 commit de2e72575fe2ea314285511c2039347c8214c056 Author: Mark Johnston AuthorDate: 2026-11-12 19:25:58 +0000 Commit: Mark Johnston CommitDate: 2026-11-17 16:57:01 +0000 sound: Improve interlocking in chn_resizebuf() chn_resizebuf() fails if the channel's software buffer is mapped, but does not take into account the fact that channel I/O drops the channel lock when copying from or to user memory. During the window where the lock is dropped, a resize may free the old buffer, causing userspace to access freed kernel memory. This can be exploited to escalate privileges. Fix this by disallowing resizing when I/O is in progress. Approved by: so Security: FreeBSD-SA-26:88.sound Security: CVE-2026-127741 Reviewed by: christos, kib Reported by: OpenAI Security Research Team Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D61446 --- sys/dev/sound/pcm/buffer.c | 1 + sys/dev/sound/pcm/channel.c | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/sys/dev/sound/pcm/buffer.c b/sys/dev/sound/pcm/buffer.c index d2cdfb13e32a..9762c54d3b59 100644 --- a/sys/dev/sound/pcm/buffer.c +++ b/sys/dev/sound/pcm/buffer.c @@ -97,6 +97,7 @@ sndbuf_busy(struct snd_dbuf *b) return (refcount_load(&b->refcount) > 1 || (b->flags & SNDBUF_F_DETACHED) != 0 || + b->channel->inprog != 0 || /* * XXX-MJ CHN_F_MMAP is not reliable, but for software buffers the * refcount accurately reflects whether the buffer is mapped. diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c index 5d429240448b..63e4788d91ee 100644 --- a/sys/dev/sound/pcm/channel.c +++ b/sys/dev/sound/pcm/channel.c @@ -1831,9 +1831,15 @@ chn_calclatency(int dir, int latency, int bps, uint32_t datarate, return blksz << blkcnt; } +static bool +chn_may_resizebuf(struct pcm_channel *c) +{ + return ((c->flags & (CHN_F_MMAP | CHN_F_TRIGGERED)) == 0 && + c->inprog == 0); +} + static int -chn_resizebuf(struct pcm_channel *c, int latency, - int blkcnt, int blksz) +chn_resizebuf(struct pcm_channel *c, int latency, int blkcnt, int blksz) { struct snd_dbuf *b, *bs, *pb; int sblksz, sblkcnt, hblksz, hblkcnt, limit = 0, nsblksz, nsblkcnt; @@ -1843,7 +1849,7 @@ chn_resizebuf(struct pcm_channel *c, int latency, if (!(c->direction == PCMDIR_PLAY || c->direction == PCMDIR_REC)) return EINVAL; - if ((c->flags & (CHN_F_MMAP | CHN_F_TRIGGERED)) != 0) + if (!chn_may_resizebuf(c)) return EINVAL; if (latency == -1) { @@ -1902,7 +1908,7 @@ chn_resizebuf(struct pcm_channel *c, int latency, CHN_UNLOCK(c->parentchannel); CHN_LOCK(c); /* Revalidate. */ - if ((c->flags & (CHN_F_MMAP | CHN_F_TRIGGERED)) != 0) + if (!chn_may_resizebuf(c)) return EINVAL; if (c->direction == PCMDIR_PLAY) { limit = (pb != NULL) ? @@ -1970,7 +1976,7 @@ chn_resizebuf(struct pcm_channel *c, int latency, } CHN_LOCK(c); /* Revalidate. */ - if ((c->flags & (CHN_F_MMAP | CHN_F_TRIGGERED)) != 0) + if (!chn_may_resizebuf(c)) return EINVAL; if (!CHN_EMPTY(c, children)) {