From nobody Thu Nov 12 08:56:15 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 4jQDl42Thyz70F0D for ; Thu, 12 Nov 2026 08:56:16 +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 4jQDl40m5Yz4n0K for ; Thu, 12 Nov 2026 08:56:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794473776; 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=La7GMnMKw1U5XlApsRdVXE2BTuO4TDtEKuOvi17cx0k=; b=btMrrUp7c+jxXJ1qxqU5MYD9rCFEr5vqrvf5ZpvIvlnW+UGyUMfvxw/08F4cysnwPbPc21 aSnTluWewTWK/l7gLGQB+Aiqu7uWZ/gCgSElG7GHOhILVzwsD/2/p82k6ZXCfpWdr6vxa+ ZOR+oXpx9CMRlpqtp6I3OkQYRBjggDwgJ/76t7LmYkThiyrGiGwoVMiwgBSsEK3HXTHJX+ gWFim5cNLtVBwj1mornsFRol5CXKJR2rllUwvmMv9v2GFkkP3pMzwzTbdQLffQy0gcrCJu Nf2cSLvJulyL51Y+CdXJqN6GN0IZeORY1TSUSNqDufCWrIqvkF+35TN3QnjnRg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794473776; b=ko+I9oXlf1wx/Ml6YROFta9WxQodK7Z5yCOJcV+9L5mJIFRK3C7fgwaoxEeQih8QRmWH6u 8aIYE5AhK+Yvd4VJMGlxZNFMkOajr/xHzErTzNntvuD2wlD1tf+2AGT45qh/SnWkkNNFkF P1K5tLSpOcjT/f0+iL8ILYPrIopDURGUbcHHrV68YiO560Zr7ZC7nmEiP0nfGKQR2DZgHu /ZVHz6GUTpNwUGKzEjqnnWD07DX/gvQqy/NESeyhJ7Z854fOcZ45YmUZ/b3FGqqTauqG0j t1zEHTI64bMxVQdk418BOPhEdDD05J/4Kc3lpK0l+pkvyVq1bbHYinvAeCdwTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794473776; 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=La7GMnMKw1U5XlApsRdVXE2BTuO4TDtEKuOvi17cx0k=; b=uSj39gysljze79uk5XaWYoY0zMk1b5dHtCQBQeP8ammDhtAdA31yYq+kjq6j7caGRjIbbH GbSB7P6R/NCyEVTJvo1Bpwcnuq1zZwxXPPeFvCaFj5b6FMBMGKM6q7/Di/mpHTy+uqqBQh Vh81pl8mVVqoDmAQaS1hesB9BOiPwZHMiuMEQ4eQA5f4rcc2/fLjA4MEaMVf39YyNUB8tt 1XWiK900hMc92QXjTDgCcjYBhh7oenD7G5q+sbmlgthAhIMV5CD6qHNW3uGze/lrROoQCf Gdg4+zkxISoVy2Y1DHHHfOH9V7aqMVr9Lk7Aihaa2TOdxr3qRQJiVyhXNBtSGw== 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 4jQDl374NrzwGl for ; Thu, 12 Nov 2026 08:56:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 18878 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 12 Nov 2026 08:56:15 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Christos Margiolis Subject: git: f4be8585afe7 - stable/15 - snd_envy24ht: Fix out-of-bounds DMA buffer indexing 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: christos X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: f4be8585afe720b8f72c154ac134b618d9410ddc Auto-Submitted: auto-generated Date: Thu, 12 Nov 2026 08:56:15 +0000 Message-Id: <6af57f2f.18878.fc2448c@gitrepo.freebsd.org> The branch stable/15 has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=f4be8585afe720b8f72c154ac134b618d9410ddc commit f4be8585afe720b8f72c154ac134b618d9410ddc Author: Christos Margiolis AuthorDate: 2026-11-03 10:28:58 +0000 Commit: Christos Margiolis CommitDate: 2026-11-12 08:56:07 +0000 snd_envy24ht: Fix out-of-bounds DMA buffer indexing 378e0c5c8967 reduced the number of playback channels from 5 to 1. This introduced a regression, because the global DMA buffer indexing was not adapted accordingly, which now results in kernel panics because of out-of-bounds reads into the buffer. Additionally, because of wrong indexing, recording channels ended up being serviced by the playback part of envy24ht_intr(). Register 1 recording channel instead of 2 + sc->adcn, as the recording DMA buffer only has room for 1 stereo stream. With 1 channel per direction, give each channel the first index of its direction (ENVY24HT_CHAN_PLAY_DAC1 and ENVY24HT_CHAN_REC_ADC1). While here, fix the buffer wrap in envy24ht_r16sl(). It has to be ch->size / ch->unit, but was copied verbatim from the 32-bit equivalent, whose samples are twice as large, so 16-bit recording wrapped halfway through the DMA buffer and never read the second half. Fixes: 378e0c5c8967 PR: 299952 MFC after: 1 week Sponsored by: The FreeBSD Foundation Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D61155 (cherry picked from commit dbf51f8ed0a5bda749dd20aedca67ddcdfe70980) --- sys/dev/sound/pci/envy24ht.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/sys/dev/sound/pci/envy24ht.c b/sys/dev/sound/pci/envy24ht.c index 9818b716510f..a512676c5be1 100644 --- a/sys/dev/sound/pci/envy24ht.c +++ b/sys/dev/sound/pci/envy24ht.c @@ -171,7 +171,6 @@ struct sc_info { struct pcmchan_caps caps[2]; /* channel info table */ - unsigned chnum; struct sc_chinfo chan[11]; }; @@ -1448,7 +1447,7 @@ envy24ht_r16sl(struct sc_chinfo *ch) dst = sndbuf_getfreeptr(ch->buffer) / 2; src = dst / 2 + ch->offset; dsize = ch->size / 2; - ssize = ch->size / 8; + ssize = ch->size / 4; slot = (ch->num - ENVY24HT_CHAN_REC_ADC1) * 2; for (i = 0; i < length; i++) { @@ -1477,14 +1476,13 @@ envy24htchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_chan device_printf(sc->dev, "envy24htchan_init(obj, devinfo, b, c, %d)\n", dir); #endif mtx_lock(&sc->lock); -#if 0 - if ((sc->chnum > ENVY24HT_CHAN_PLAY_SPDIF && dir != PCMDIR_REC) || - (sc->chnum < ENVY24HT_CHAN_REC_ADC1 && dir != PCMDIR_PLAY)) { - mtx_unlock(&sc->lock); - return NULL; - } -#endif - num = sc->chnum; + /* + * Only 1 channel per direction is registered at the moment (see + * pcm_addchan() calls in envy24ht_pci_attach()), so only the first + * pair of slots in each frame is used. + */ + num = dir == PCMDIR_PLAY ? ENVY24HT_CHAN_PLAY_DAC1 : + ENVY24HT_CHAN_REC_ADC1; ch = &sc->chan[num]; ch->size = 8 * ENVY24HT_SAMPLE_NUM; @@ -1498,8 +1496,7 @@ envy24htchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_chan ch->channel = c; ch->parent = sc; ch->dir = dir; - /* set channel map */ - ch->num = envy24ht_chanmap[num]; + ch->num = num; mtx_unlock(&sc->lock); sndbuf_setup(ch->buffer, ch->data, ch->size); mtx_lock(&sc->lock); @@ -2481,16 +2478,8 @@ envy24ht_pci_attach(device_t dev) /* set multi track mixer */ mixer_init(dev, &envy24htmixer_class, sc); - /* set channel information */ - sc->chnum = 0; - /* for (i = 0; i < 5; i++) { */ - pcm_addchan(dev, PCMDIR_PLAY, &envy24htchan_class, sc); - sc->chnum++; - /* } */ - for (i = 0; i < 2 + sc->adcn; i++) { - pcm_addchan(dev, PCMDIR_REC, &envy24htchan_class, sc); - sc->chnum++; - } + pcm_addchan(dev, PCMDIR_PLAY, &envy24htchan_class, sc); + pcm_addchan(dev, PCMDIR_REC, &envy24htchan_class, sc); /* set status iformation */ snprintf(status, SND_STATUSLEN,