diff --git a/share/man/man4/pcm.4 b/share/man/man4/pcm.4 index 518c37b54f1..8a92cefa354 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 7bc1decc283..d9726ffdd6b 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; - /* - * 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 + /* + * https://lists.freebsd.org/pipermail/freebsd-emulation/2007-June/003698.html + */ 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);