1e6769554SRui Paulo.\" Copyright (c) 2000 Sheldon Hearn 2e6769554SRui Paulo.\" All rights reserved. 3e6769554SRui Paulo.\" 4e6769554SRui Paulo.\" Redistribution and use in source and binary forms, with or without 5e6769554SRui Paulo.\" modification, are permitted provided that the following conditions 6e6769554SRui Paulo.\" are met: 7e6769554SRui Paulo.\" 1. Redistributions of source code must retain the above copyright 8e6769554SRui Paulo.\" notice, this list of conditions and the following disclaimer. 9e6769554SRui Paulo.\" 2. Redistributions in binary form must reproduce the above copyright 10e6769554SRui Paulo.\" notice, this list of conditions and the following disclaimer in the 11e6769554SRui Paulo.\" documentation and/or other materials provided with the distribution. 12e6769554SRui Paulo.\" 13e6769554SRui Paulo.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14e6769554SRui Paulo.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15e6769554SRui Paulo.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16e6769554SRui Paulo.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17e6769554SRui Paulo.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18e6769554SRui Paulo.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19e6769554SRui Paulo.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20e6769554SRui Paulo.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21e6769554SRui Paulo.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22e6769554SRui Paulo.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23e6769554SRui Paulo.\" SUCH DAMAGE. 24e6769554SRui Paulo.\" 259a9677ecSRicardo Branco.Dd May 19, 2024 26c383d55bSGavin Atkinson.Dt LINUX 4 27e6769554SRui Paulo.Os 28e6769554SRui Paulo.Sh NAME 29e6769554SRui Paulo.Nm linux 30e6769554SRui Paulo.Nd Linux ABI support 31e6769554SRui Paulo.Sh SYNOPSIS 32bd8077eeSEdward Tomasz NapieralaTo enable the Linux ABI at boot time, place the following line in 33bd8077eeSEdward Tomasz Napierala.Xr rc.conf 5 : 34e6769554SRui Paulo.Bd -literal -offset indent 35bd8077eeSEdward Tomasz Napieralalinux_enable="YES" 36e6769554SRui Paulo.Ed 37e6769554SRui Paulo.Sh DESCRIPTION 38e6769554SRui PauloThe 39e6769554SRui Paulo.Nm 40595532a7SEdward Tomasz Napieralakernel module provides limited Linux ABI (application binary interface) 41595532a7SEdward Tomasz Napieralacompatibility, making it possible to run many unmodified Linux applications 42f54d9519SEdward Tomasz Napieralawithout the need for virtualization or emulation. 43f54d9519SEdward Tomasz NapieralaSome of the facilities provided are: 44e6769554SRui Paulo.Bl -bullet 45e6769554SRui Paulo.It 46e6769554SRui PauloLinux to native system call translation 47f54d9519SEdward Tomasz Napierala.It 48f54d9519SEdward Tomasz NapieralaLinux-specific system calls 49bd8077eeSEdward Tomasz Napierala.It 50bd8077eeSEdward Tomasz NapieralaSpecial signal handling for Linux processes 51bd8077eeSEdward Tomasz Napierala.It 52bd8077eeSEdward Tomasz NapieralaPath translation mechanism 53bd8077eeSEdward Tomasz Napierala.It 54bd8077eeSEdward Tomasz NapieralaLinux-specific virtual file systems 55e6769554SRui Paulo.El 56e6769554SRui Paulo.Pp 57bd8077eeSEdward Tomasz NapieralaThe path translation mechanism makes Linux processes look up file paths 58bd8077eeSEdward Tomasz Napieralaunder 59bd8077eeSEdward Tomasz Napierala.Va emul_path 60bd8077eeSEdward Tomasz Napierala(defaulting to 61bd8077eeSEdward Tomasz Napierala.Pa /compat/linux ) 62bd8077eeSEdward Tomasz Napieralabefore 63bd8077eeSEdward Tomasz Napierala.Pa / . 64*d1daec3dSEd MasteFor example, when a Linux process attempts to open 65bd8077eeSEdward Tomasz Napierala.Pa /etc/passwd , 66f66e71faSEd Masteit will first access 67bd8077eeSEdward Tomasz Napierala.Pa /compat/linux/etc/passwd , 68f66e71faSEd Mastefalling back to 69f66e71faSEd Maste.Pa /etc/passwd 70*d1daec3dSEd Masteif the compat path does not exist. 71bd8077eeSEdward Tomasz NapieralaThis is used to make sure Linux processes load Linux shared libraries 72bd8077eeSEdward Tomasz Napieralainstead of their similarly-named FreeBSD counterparts, and also 73bd8077eeSEdward Tomasz Napieralato provide alternative versions of certain other files and virtual 74f54d9519SEdward Tomasz Napieralafile systems. 75bd8077eeSEdward Tomasz Napierala.Pp 76bd8077eeSEdward Tomasz NapieralaTo install Linux shared libraries and system files into 77bd8077eeSEdward Tomasz Napierala.Pa /compat/linux , 78595532a7SEdward Tomasz Napieralaeither use the 79f54d9519SEdward Tomasz Napierala.Pa emulators/linux_base-c7 80595532a7SEdward Tomasz Napieralaport or package, 81595532a7SEdward Tomasz Napieralaor 82595532a7SEdward Tomasz Napierala.Xr debootstrap 8 83595532a7SEdward Tomasz Napieralainstalled from 84595532a7SEdward Tomasz Napierala.Pa sysutils/debootstrap . 85bd8077eeSEdward Tomasz Napierala.Pp 86bd8077eeSEdward Tomasz NapieralaTo avoid mounting Linux-specific filesystems at startup, add the following 87bd8077eeSEdward Tomasz Napieralaline to the 88f54d9519SEdward Tomasz Napierala.Xr rc.conf 5 89f54d9519SEdward Tomasz Napieralafile: 90e6769554SRui Paulo.Pp 91f54d9519SEdward Tomasz Napierala.Dl linux_mounts_enable="NO" 92f54d9519SEdward Tomasz Napierala.Sh SYSCTL VARIABLES 93f54d9519SEdward Tomasz NapieralaThe following variables are available as both 94e6769554SRui Paulo.Xr sysctl 8 95f54d9519SEdward Tomasz Napieralavariables and 96f54d9519SEdward Tomasz Napierala.Xr loader 8 97f54d9519SEdward Tomasz Napieralatunables: 98f54d9519SEdward Tomasz Napierala.Bl -tag -width indent 99462171d9SEdward Tomasz Napierala.It Va compat.linux.debug 100462171d9SEdward Tomasz NapieralaEnable debugging messages. 101462171d9SEdward Tomasz NapieralaSet to 0 to silence them. 1028ec6c4a3SAlexander LeidingerDefaults to 3. 1038ec6c4a3SAlexander LeidingerA setting of 1 prints debug messages, tells about unimplemented stuff (only 1048ec6c4a3SAlexander Leidingeronce). 1058ec6c4a3SAlexander LeidingerSet to 2 is like 1, but also prints messages about implemented but not tested 1068ec6c4a3SAlexander Leidingerstuff (only once). 1078ec6c4a3SAlexander LeidingerSetting it to 3 or higher is like 2, but no rate limiting of messages. 1088c5059e9SEdward Tomasz Napierala.It Va compat.linux.default_openfiles 1098c5059e9SEdward Tomasz NapieralaDefault soft openfiles resource limit for Linux applications. 1108c5059e9SEdward Tomasz NapieralaSet to -1 to disable the limit. 1118c5059e9SEdward Tomasz NapieralaDefaults to 1024. 112b5f20658SEdward Tomasz Napierala.It Va compat.linux.emul_path 113b5f20658SEdward Tomasz NapieralaPath to the Linux run-time environment. 114b5f20658SEdward Tomasz NapieralaDefaults to 115b5f20658SEdward Tomasz Napierala.Pa /compat/linux . 116f54d9519SEdward Tomasz Napierala.It Va compat.linux.osname 117e6769554SRui PauloLinux kernel operating system name. 118bd8077eeSEdward Tomasz NapieralaDefaults to "Linux". 119f54d9519SEdward Tomasz Napierala.It Va compat.linux.osrelease 120e6769554SRui PauloLinux kernel operating system release. 121e6769554SRui PauloChanging this to something else is discouraged on non-development systems, 122e6769554SRui Paulobecause it may change the way Linux programs work. 123bd8077eeSEdward Tomasz NapieralaSome versions of GNU libc are known to use different syscalls depending 124e6769554SRui Pauloon the value of this sysctl. 125f54d9519SEdward Tomasz Napierala.It Va compat.linux.oss_version 126e6769554SRui PauloLinux Open Sound System version. 127bd8077eeSEdward Tomasz NapieralaDefaults to 198144. 1282cf9eb6cSEdward Tomasz Napierala.It Va compat.linux.preserve_vstatus 1292cf9eb6cSEdward Tomasz NapieralaWhen set to 1, it prevents Linux applications from resetting the 1302cf9eb6cSEdward Tomasz Napierala.Xr termios 4 1312cf9eb6cSEdward Tomasz NapieralaVSTATUS setting. 1322cf9eb6cSEdward Tomasz NapieralaFrom a user perspective, this makes 1332cf9eb6cSEdward Tomasz Napierala.Va SIGINFO 1342cf9eb6cSEdward Tomasz Napieralawork for Linux executables. 135b896bdb8SEdward Tomasz NapieralaDefaults to 1. 136598f6fb4SKonstantin Belousov.It Va compat.linux.setid_allowed 137595532a7SEdward Tomasz NapieralaEnable handling of set-user-ID and set-group-ID mode bits for the new 138598f6fb4SKonstantin Belousovprocess image file when image is to be executed under Linux ABI. 139595532a7SEdward Tomasz NapieralaWhen set to 0, new Linux images always use credentials of the program 140bd8077eeSEdward Tomasz Napieralathat issued the 141598f6fb4SKonstantin Belousov.Xr execve 2 142598f6fb4SKonstantin Belousovcall, regardless of the image file mode. 143598f6fb4SKonstantin BelousovThis might be reasonable or even required, because 144598f6fb4SKonstantin Belousov.Fx 145595532a7SEdward Tomasz Napieraladoes not emulate the Linux environment completely, and missed features 146595532a7SEdward Tomasz Napieralamay result in security vulnerabilities. 147595532a7SEdward Tomasz NapieralaDefaults to 1. 148d5dc757eSDmitry Chagin.It Va compat.linux32.emulate_i386 149d5dc757eSDmitry ChaginIn the x86_64 (amd64) world enable the real i386 Linuxulator behavior. 150d5dc757eSDmitry ChaginFor example, when set to 0, Linux uname -m will return "x86_64" even if 151d5dc757eSDmitry Chaginuname itself is a i386 Linux executable. When set to 1, Linux i386 152d5dc757eSDmitry Chaginuname -m will return "i686". 153d5dc757eSDmitry ChaginDefaults to 0. 154d458747eSChristian Brueffer.El 155e6769554SRui Paulo.Sh FILES 156f54d9519SEdward Tomasz Napierala.Bl -tag -width /compat/linux/dev/shm -compact 157e6769554SRui Paulo.It Pa /compat/linux 158bd8077eeSEdward Tomasz NapieralaLinux run-time environment 1596bc92736SEdward Tomasz Napierala.It Pa /compat/linux/dev 1606bc92736SEdward Tomasz Napieraladevice file system, see 1611a720cbeSAlexander Ziaee.Xr devfs 4 16277d3337cSDmitry Chagin.It Pa /compat/linux/dev/fd 1636ef8f9d2SEdward Tomasz Napieralafile descriptor file system mounted with the 1646ef8f9d2SEdward Tomasz Napierala.Cm linrdlnk 1656ef8f9d2SEdward Tomasz Napieralaoption, see 1661a720cbeSAlexander Ziaee.Xr fdescfs 4 1679a9677ecSRicardo Branco.It Pa /compat/linux/dev/mqueue 1689a9677ecSRicardo Brancosymbolic link to a mqueuefs mount, see 1699a9677ecSRicardo Branco.Xr mqueuefs 4 170f54d9519SEdward Tomasz Napierala.It Pa /compat/linux/dev/shm 171f54d9519SEdward Tomasz Napieralain-memory file system, see 1721a720cbeSAlexander Ziaee.Xr tmpfs 4 173e6769554SRui Paulo.It Pa /compat/linux/proc 174f54d9519SEdward Tomasz NapieralaLinux process file system, see 1751a720cbeSAlexander Ziaee.Xr linprocfs 4 176e6769554SRui Paulo.It Pa /compat/linux/sys 177f54d9519SEdward Tomasz NapieralaLinux kernel objects file system, see 1781a720cbeSAlexander Ziaee.Xr linsysfs 4 179e6769554SRui Paulo.El 180e6769554SRui Paulo.Sh SEE ALSO 181e6769554SRui Paulo.Xr brandelf 1 , 1821a720cbeSAlexander Ziaee.Xr fdescfs 4 , 1831a720cbeSAlexander Ziaee.Xr linprocfs 4 , 1841a720cbeSAlexander Ziaee.Xr linsysfs 4 , 1859a9677ecSRicardo Branco.Xr mqueuefs 4 , 186fd2ced61SEdward Tomasz Napierala.Xr pty 4 , 1871a720cbeSAlexander Ziaee.Xr tmpfs 4 , 1881a720cbeSAlexander Ziaee.Xr elf 5 189e6769554SRui Paulo.Sh HISTORY 190595532a7SEdward Tomasz NapieralaLinux ABI support first appeared for i386 in 191e6769554SRui Paulo.Fx 2.1 . 192bd8077eeSEdward Tomasz NapieralaSupport for amd64 binaries first appeared in 193bd8077eeSEdward Tomasz Napierala.Fx 10.3 . 194bd8077eeSEdward Tomasz NapieralaSupport for arm64 binaries first appeared in 195bd8077eeSEdward Tomasz Napierala.Fx 12.0 . 196f54d9519SEdward Tomasz Napierala.Sh BUGS 197f54d9519SEdward Tomasz NapieralaSupport for some of the Linux-specific system calls and system call arguments 198f54d9519SEdward Tomasz Napieralais missing. 199