From nobody Fri May 15 15:08:51 2026 X-Original-To: dev-commits-src-main@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 4gH9ZW4B1wz6dRjG for ; Fri, 15 May 2026 15:08:51 +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 "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gH9ZW3TGlz47XY for ; Fri, 15 May 2026 15:08:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1778857731; 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=9HXRzzbNo5OwEOVe/OpJWvz+kGoIeANdlh0xflbgD/4=; b=hckHyW34gk7PlVDsnyplmE5Dmn3f5/fSdAc44WFnoVhE8LE3jg56fPU9hFw3B5qC70tBld adRtIrQtrgXOiFB5qFw6nzL01VHNyzz0KUUa+4XUJyuQwJblFoy29qF5W4UE3dCr7onIOX xpvQkOo91E8IXn6lL4TWWvINFB3G5BgJvf3teaDRPBYub+HozGYU1eNWxFykpjtRkSXbLW gnqXwOJoPJJAOkS61pCb+f6FeyFhpqU2oMRR9wEe8umJNutbeqAGAwMpjoifYwXrDv5GB9 qAKWVnEDETwZSqz9GhsdMNYjvMxdcKHx0X72MmOGXwvIuOZJbXZPWiU7UtA9rg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1778857731; a=rsa-sha256; cv=none; b=APDbHFX7QBEpjztTunrmFnIreGPqpH0lPsULmD/G3C9BUDfLmxCJoCalyIzoK9mkwl2VW2 2jW5ZmBLvC4Shgz49SdDLR82ne3Dtriloz8sE0xAKbVhXN7UL8mUFHkBGkpZx05Ue2Oeiw vjIO5ZXD2hUtrautTRrhjoQcJBZ0X4ZnhkWff8fZ14pseJPDc1kn6qSafHJ8ikgOoB2Cpe VCWxDd96lAUnOWnuKMKq9cYQSsp9loK7od5E7edN9z/Zuzj2MyjjPuC/xxQpKtkIZDx3SB nNJXx4VVPeFUFTqynzCyNbe0xn6EPtz/pKjK7XnS/yEI9J8x6+eQQms+5wJPnw== 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=1778857731; 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=9HXRzzbNo5OwEOVe/OpJWvz+kGoIeANdlh0xflbgD/4=; b=Mf6YzQb/ujfPAnpE2t6bKNbnFxeW9/LpVA6xgM1QnIVLFQW67y+2ykKP/gAOuuy3+Fg2XR aDOYsQNjDplnFdgUBeNL8Y1GArx49s57eJmwvLHkAH0RUgkk7kwLVswFTLK5+LPGPsAxoy qZ1VUGQbVux0psML6LixDeWbba3bRr4qIzKmTHMhNPRl2gFV+oubrM/wPUxfEUfbEoiMXz d4eNs8dlnOGbSiTmnNqnw3mBz9keqAWprnvvqry+NdnssxVa4dWl1kObRn5E+v9RF7jTw9 /lshAK3b99IvAh3FcJBDtBcFCbb9lxeuWiCgT2kH3LS/AULX9D8V5jpwWHifww== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gH9ZW34D7z1QY7 for ; Fri, 15 May 2026 15:08:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3403a by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 15 May 2026 15:08:51 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Christos Margiolis Subject: git: b9c10eeb380b - main - sound: Improve hw.snd.compat_linux_mmap List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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: christos X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b9c10eeb380b3ba629421062af8658e79a9171cd Auto-Submitted: auto-generated Date: Fri, 15 May 2026 15:08:51 +0000 Message-Id: <6a073703.3403a.3477a5a@gitrepo.freebsd.org> The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=b9c10eeb380b3ba629421062af8658e79a9171cd commit b9c10eeb380b3ba629421062af8658e79a9171cd Author: Christos Margiolis AuthorDate: 2026-05-15 14:07:59 +0000 Commit: Christos Margiolis CommitDate: 2026-05-15 15:08:11 +0000 sound: Improve hw.snd.compat_linux_mmap - Reject PROT_EXEC in all cases when Linux support is not compiled in. - Define sysctl only when Linux support is compiled in. - Document better. Sponsored by: The FreeBSD Foundation MFC after: 1 week Reviewed by: emaste Pull Request: https://ron-dev.freebsd.org/FreeBSD/src/pulls/29 --- share/man/man4/pcm.4 | 26 +++++++++++++++++--------- sys/dev/sound/pcm/dsp.c | 13 +++++-------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/share/man/man4/pcm.4 b/share/man/man4/pcm.4 index 518c37b54f1d..8a92cefa3549 100644 --- a/share/man/man4/pcm.4 +++ b/share/man/man4/pcm.4 @@ -23,7 +23,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd February 15, 2025 +.Dd May 15, 2026 .Dt SOUND 4 .Os .Sh NAME @@ -254,21 +254,29 @@ are global settings and are device specific. .Bl -tag -width indent .It Va hw.snd.compat_linux_mmap -Linux +This +.Xr sysctl 8 +variable is available only when Linux application support is compiled into the +kernel, and affects Linux binaries only. +It is a hack to get around the fact that, for i386 emulation, +.Xr linux 4 +historically set PROT_EXEC automatically when PROT_READ or PROT_WRITE was set +during an .Xr mmap 2 -compatibility. +call, which +.Fx +does not. +.Pp The following values are supported (default is 0): .Bl -tag -width 2n .It -1 -Force disabling/denying PROT_EXEC +Force-disable PROT_EXEC .Xr mmap 2 -requests. +requests, even for Linux applications. .It 0 -Auto detect proc/ABI type, allow +Allow PROT_EXEC .Xr mmap 2 -for Linux applications, and deny for everything else. -.It 1 -Always allow PROT_EXEC page mappings. +requests for Linux applications only. .El .It Va hw.snd.default_auto Automatically assign the default sound unit. diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c index 7bc1decc283b..d9726ffdd6bb 100644 --- a/sys/dev/sound/pcm/dsp.c +++ b/sys/dev/sound/pcm/dsp.c @@ -54,10 +54,12 @@ struct dsp_cdevpriv { struct pcm_channel *wrch; }; +#ifdef SV_ABI_LINUX static int dsp_mmap_allow_prot_exec = 0; SYSCTL_INT(_hw_snd, OID_AUTO, compat_linux_mmap, CTLFLAG_RWTUN, &dsp_mmap_allow_prot_exec, 0, - "linux mmap compatibility (-1=force disable 0=auto 1=force enable)"); + "linux mmap compatibility (-1=force-disable 0=auto)"); +#endif static int dsp_basename_clone = 1; SYSCTL_INT(_hw_snd, OID_AUTO, basename_clone, CTLFLAG_RWTUN, @@ -1923,20 +1925,15 @@ dsp_mmap_single(struct cdev *i_dev, vm_ooffset_t *offset, struct pcm_channel *wrch, *rdch, *c; int err; +#ifdef SV_ABI_LINUX /* - * Reject PROT_EXEC by default. It just doesn't makes sense. - * Unfortunately, we have to give up this one due to linux_mmap - * changes. - * * https://lists.freebsd.org/pipermail/freebsd-emulation/2007-June/003698.html - * */ -#ifdef SV_ABI_LINUX if ((nprot & PROT_EXEC) && (dsp_mmap_allow_prot_exec < 0 || (dsp_mmap_allow_prot_exec == 0 && SV_CURPROC_ABI() != SV_ABI_LINUX))) #else - if ((nprot & PROT_EXEC) && dsp_mmap_allow_prot_exec < 1) + if (nprot & PROT_EXEC) #endif return (EINVAL);