From nobody Tue Nov 17 17:08:26 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 4jTWQf4T34z71SPQ for ; Tue, 17 Nov 2026 17:08:26 +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 4jTWQf2NFKz4N04 for ; Tue, 17 Nov 2026 17:08:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794935306; 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=JkbnN7unW2xvbdnFZgHiZbTOqiwQiOAJrRRS3kycUqI=; b=S68UL+MOoONTkRoFKCdVaShT6bEShqOwCpMeGLKinolkXfUEbg7KKcxzwIoz4Ggy4ffMCG tzuEBmx1FT9DvjMIsJPRBFSE9I3DyQPBfIEK6ioVJK/Km2Ydb/nexs46lf//zA8kIgd0AX QJkLevsUxZJ5sfkN3jTMXD+kfxCm+qGIJpxAGqSOu4mnrP/WF+RPlTwB8zyQkvFAiXE+hZ mfl8I7l2EAFgyzKG636L5aJHKAK8+iZ1rLy4lblFs2aU7m/hw6Lf618eyHSjbsAb2GaqSy utMESC9MZuxPXHmIGNCKz7aW3QGG91VvvseFF5u878XCyVrkqq2hcrxU/mz3jQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794935306; b=ewHfd8rf2qCmag0XF60JYBEhAwUY9lsHjefWd9Vsyq2JrTtzGpZb8kk2xCaVoaYqNWvT2r TT5/d9jrIdglrfQ2N5KJprt4Yb2A+Gstk7vCdT4uWqgXcbfT3sX3nYPN5w2pOi72V6J0d5 yGTLXeNlrAETcNTd0FTEBLg+R+JI6jrfODfhMramxgQa2c+wHw46L2PmX8JHg9vX676ZHp LluambIvrO19CbIxzNJj+YGGk55cyg7539lSxocDJA3MKMluH8RqYqgZETm+nT6qu0UDxZ 6UvMoM2b0P5WOz5jMc8vjAD2scWGeTnVAmowGmsTQRi0d+eSDHgykCWdAqIvjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794935306; 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=JkbnN7unW2xvbdnFZgHiZbTOqiwQiOAJrRRS3kycUqI=; b=UVGnNng4aK9PtZTK8N+OSOWXkpV3487hlYzK6wmcb9Jp//5ciV38QycLSOZjN/0EdxiRBF 2skEA+ub3UvDd7rc19eApAOlQfgwHx9+c3XB+yMpVsVeG2QgKJ63HHziSaBlPnrDrVSg2B wYwvg6ql6YG62naGyKUofaFTHZuT3XgY3Yn2vMNHFv917sH9n6S2rXuXa0jAsryF2/h3vD 2OW+93AXu3Bgm8rnL7X0tWi0ypnS74PL/82MeTwsoqXmdAbRU2Wutp8Z28KSuN0EZ5mMrH fd85KE/2HoTmlT9vEl5AF9W0L0r3Da/oe3IDP2gVyd+rjCrES3Dkgr3iiIAPGA== 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 4jTWQf22bJzrw2 for ; Tue, 17 Nov 2026 17:08:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1d169 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 17 Nov 2026 17:08:26 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 2c29a955d314 - releng/15.1 - 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/releng/15.1 X-Git-Reftype: branch X-Git-Commit: 2c29a955d3143c4916b2a7d002979386f428b15b Auto-Submitted: auto-generated Date: Tue, 17 Nov 2026 17:08:26 +0000 Message-Id: <6afc8a0a.1d169.4cd9b06a@gitrepo.freebsd.org> The branch releng/15.1 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=2c29a955d3143c4916b2a7d002979386f428b15b commit 2c29a955d3143c4916b2a7d002979386f428b15b Author: Mark Johnston AuthorDate: 2026-11-12 19:25:58 +0000 Commit: Mark Johnston CommitDate: 2026-11-16 21:25:03 +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 9e212f646737..c81876758c6f 100644 --- a/sys/dev/sound/pcm/buffer.c +++ b/sys/dev/sound/pcm/buffer.c @@ -94,6 +94,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 dfebdaefbaeb..7dcf6a2e58d0 100644 --- a/sys/dev/sound/pcm/channel.c +++ b/sys/dev/sound/pcm/channel.c @@ -1814,9 +1814,15 @@ chn_calclatency(int dir, int latency, int bps, u_int32_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; @@ -1825,7 +1831,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) { @@ -1883,7 +1889,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) ? @@ -1941,7 +1947,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)) {