Home | History | Annotate | Download | only in common
History log of /src/sys/compat/linux/common/linux_ipc.c
RevisionDateAuthorComments
 1.58  27-Jun-2025  andvar Fix various typos, mainly in comments.
 1.57  23-Aug-2019  maxv Fix stupid bugs in linux_sys_shmctl(): the index could be out of bound
(page fault) and there was no proper locking.

Maybe we should just remove LINUX_SHM_STAT, like compat_linux32.
 1.56  21-Feb-2019  mrg branches: 1.56.4;
for sysv ipc stat operations, explicitly copy the exported parts
instead of the whole ds structure.

besides triggering a recently added assert in netbsd32, this stops
exposing kernel addresses.

copy the mode clamping to 0777 from sem to shm and msg.


while here, make sure that the compat callers to sysv_ipc clear
the contents of the compat structure before setting the result
members to ensure padding bytes are cleared.

don't set/copy _sem_base, _msg_first, _msg_last or _shm_internal.
even if used, which seems very dodgy, they leak KVAs as well.
possibly this may affect linux binaries, in particular, the
comments around _shm_internal ("XXX Oh well.") may mean apps
rely upon these but hopefully not -- the comments date back to
rev 1.1 in 1995.

the _key, _seq and _msg_cbytes members are exported as before as
i found multiple consumers of these (no less than ipcs(1), and
they appear to be useful for debugging and more.


XXX: the naming of compat functions have too many styles. there
are at least 3 different ones changed here.
 1.55  28-May-2011  alnsn branches: 1.55.30; 1.55.34; 1.55.42; 1.55.48; 1.55.56;
Fix typo in a comment.
 1.54  16-Nov-2009  joerg branches: 1.54.4; 1.54.6;
Make sure to never leak padding space before copyout or copyin
uninitialized fields by explicitly using memset in the conversion
routines.
 1.53  23-Apr-2009  njoly Add IPC_64 support for all semctl(2)/msgctl(2). Needed, at least on
i386 for Linux 2.6 emulation.
 1.52  18-Feb-2009  njoly Add IPC_64 support for all shmctl(2) commands, not only for STAT/SET.
This make it work on i386 under 2.6 emulation.
 1.51  21-May-2008  njoly branches: 1.51.6; 1.51.12;
Add IPC_64 support to msgctl, needed for amd64.
 1.50  28-Apr-2008  martin branches: 1.50.2;
Remove clause 3 and 4 from TNF licenses
 1.49  24-Apr-2008  njoly branches: 1.49.2;
Add IPC_64 support for semctl IPC_STAT/IPC_SET.
 1.48  21-Apr-2008  njoly Add LINUX_IPC_64 support for LINUX_IPC_SET in shmctl. Required, at
least, for amd64 which use LINUX_IPC_FORCE64.
 1.47  21-Apr-2008  njoly Rename LINUX_SHMCTL_FORCEIPC64 define to LINUX_IPC_FORCE64.
 1.46  16-Apr-2008  njoly branches: 1.46.2;
Remove an obsolete comment about SHM_LOCK/SHM_UNLOCK being no-op.
 1.45  15-Apr-2008  njoly Remove unneeded amd64 ifdef/endif.
 1.44  28-Jan-2008  njoly branches: 1.44.6;
Make shmctl + {IPC,SHM}_STAT work an amd64, by forcing use of IPC_64.
Following the Linux kernel behaviour.
 1.43  28-Jan-2008  njoly shmctl fixes.

- SHM_STAT take an index as input, and return the corresponding shmid.
- IPC_INFO and SHM_INFO returns the highest used index.
- SHM_INFO expected the total used pages (not bytes) in shm_tot field
of struct shm_info.
 1.42  20-Dec-2007  dsl Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.41  08-Dec-2007  dsl branches: 1.41.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.40  17-Jun-2007  dsl branches: 1.40.6; 1.40.8; 1.40.14; 1.40.16;
Do the sysv ipc calls without the stackgap.
 1.39  04-Mar-2007  christos branches: 1.39.2; 1.39.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.38  09-Feb-2007  ad branches: 1.38.2;
Merge newlock2 to head.
 1.37  13-Sep-2006  manu Jumbo COMPAT_LINUX/COMPAT_LINUX32 bugfix, with the help of Nicolas Joly
- Fix shmat return value on amd64: it uses no black magic with retval[0]
- Fix integer overflows in sysinfo
- Implement sysinfo, mmap2, sched_getparam, sched_getscheduler, mremap,
and madvise in COMPAT_LINUX32
- Fix improper types used in setgroups16/getgroups16
- Implement mmap2 for COMPAT_LINUX32
- Ifdef debug messages by DEBUG_LINUX
 1.36  24-Aug-2006  manu branches: 1.36.2;
The return value for Linux shmat on amd64 does not suffer the same horrible
hack as on i386.
 1.35  23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.34  09-Feb-2006  dogcow branches: 1.34.2;
make linux emulation compile on i386 again.
 1.33  09-Feb-2006  manu Add initial (but unfinished) COMPAT_LINUX32 for amd64. This is good enough so
that the i386 license manager part of amd64 version of Fluent works.

While I'm here, add SysV IPC to COMPAT_LINUX/amd64
 1.32  10-Nov-2005  christos branches: 1.32.4; 1.32.6; 1.32.8;
More ipc support for linux; makes oracle work. From chuq and
jlrodriguez at terra dot es
 1.31  26-Feb-2005  perry branches: 1.31.4;
nuke trailing whitespace
 1.30  28-Sep-2004  jdolecek branches: 1.30.4; 1.30.6;
add flag for shmget(2) to specify that later shmat(2) for the shared memory
segment should succeed even if the segment would be marked removed; use this
to implement the Linux-compatible semantics of shmat(2)

this fixes the old Linux VMware3 graphics problem with local display,
and possibly other local Linux X clients using MIT-SHM
 1.29  28-Sep-2004  jdolecek fold shmat1() back into sys_shmat(), the change in rev 1.64 is not sufficient
for Linux-compatible shmat() behaviour - shmat() for the removed shared memory
segment must work from all callers, the shared memory id could be passed e.g.
to native X server via MIT-SHM

temporarily remove the functionality, the Linux-compatible semantics
will be reimplemented differently
 1.28  18-Jan-2003  thorpej branches: 1.28.2; 1.28.4;
Merge the nathanw_sa branch.
 1.27  03-Apr-2002  fvdl Use shmat1(), and tell it to find removed segments.
 1.26  16-Mar-2002  christos make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.
 1.25  15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.24  13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.23  30-May-2001  mrg branches: 1.23.2;
use _KERNEL_OPT.
 1.22  01-Dec-2000  jdolecek branches: 1.22.2;
make LKM safe
 1.21  25-Aug-1999  thorpej branches: 1.21.2;
Update for new msgctl()/semctl()/shmctl() calls.
 1.20  27-May-1999  tron Add support for SETALL and GETALL to the Linux emulation of semctl()
and improve handling of SETVAL. Patches supplied by YAMAMOTO Jiro in
PR kern/7621.
 1.19  03-Jan-1999  erh branches: 1.19.4;
Undo previous: Put back opt_sysv.h
 1.18  03-Jan-1999  erh Moved opt include to header file.
 1.17  19-Oct-1998  tron Defopt SYSVMSG, SYSVSEM and SYSVSHM.
 1.16  04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.15  03-Oct-1998  christos Attempt to fix the mess.
 1.14  01-Oct-1998  erh Split compat/linux/linux_ipc.c into common and multi-architechture parts. The IPC multiplexer and associated functions are now in linux_ipccall.c
 1.13  22-Jan-1998  mycroft Clean this up a bit.
 1.12  08-May-1997  kleink Fixed copyin() argument botch in shmctl() IPC_STAT handling.
 1.11  15-Nov-1996  fvdl Avoid compiler warnings when none of the SYSV* options is defined.
 1.10  05-Apr-1996  christos Prototyping changes.
 1.9  08-Oct-1995  fvdl Avoid unnecessary copyin() of shmid_ds struct for shmctl(IPC_RMID)
 1.8  07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.7  19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.6  15-Aug-1995  fvdl Implement the rest of the sysv ipc calls ({sem,msg}*())
 1.5  14-Aug-1995  mycroft Rearrange #includes.
 1.4  24-Jun-1995  christos Use compat_util.[ch].
 1.3  22-Jun-1995  fvdl * Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)
 1.2  08-Mar-1995  fvdl Add missing structure conversion for IPC_RMID.
 1.1  28-Feb-1995  fvdl Added Linux compat code.
 1.19.4.1  21-Jun-1999  thorpej Sync w/ -current.
 1.21.2.1  08-Dec-2000  bouyer Sync with HEAD.
 1.22.2.8  12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.22.2.7  29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.22.2.6  17-Apr-2002  nathanw Catch up to -current.
 1.22.2.5  01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.22.2.4  08-Jan-2002  nathanw Catch up to -current.
 1.22.2.3  14-Nov-2001  nathanw Catch up to -current.
 1.22.2.2  21-Jun-2001  nathanw Catch up to -current.
 1.22.2.1  05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.23.2.2  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.23.2.1  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.28.4.1  04-Oct-2004  jmc Pullup rev 1.29 (requested by jdolecek in ticket #884)

Fix linux handling of SysV-style shared memory. Fixed Linux VMware display
problems.
 1.28.2.3  11-Dec-2005  christos Sync with head.
 1.28.2.2  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.28.2.1  19-Oct-2004  skrll Sync with HEAD
 1.30.6.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.30.4.1  29-Apr-2005  kent sync with -current
 1.31.4.6  04-Feb-2008  yamt sync with head.
 1.31.4.5  21-Jan-2008  yamt sync with head
 1.31.4.4  03-Sep-2007  yamt sync with head.
 1.31.4.3  26-Feb-2007  yamt sync with head.
 1.31.4.2  30-Dec-2006  yamt sync with head.
 1.31.4.1  21-Jun-2006  yamt sync with head.
 1.32.8.1  22-Apr-2006  simonb Sync with head.
 1.32.6.1  09-Sep-2006  rpaulo sync with head
 1.32.4.1  18-Feb-2006  yamt sync with head.
 1.34.2.3  14-Sep-2006  yamt sync with head.
 1.34.2.2  03-Sep-2006  yamt sync with head.
 1.34.2.1  11-Aug-2006  yamt sync with head
 1.36.2.2  30-Jan-2007  ad Remove support for SA. Ok core@.
 1.36.2.1  18-Nov-2006  ad Sync with head.
 1.38.2.1  12-Mar-2007  rmind Sync with HEAD.
 1.39.4.1  11-Jul-2007  mjf Sync with head.
 1.39.2.1  15-Jul-2007  ad Sync with head.
 1.40.16.1  26-Dec-2007  ad Sync with head.
 1.40.14.1  18-Feb-2008  mjf Sync with HEAD.
 1.40.8.2  23-Mar-2008  matt sync with HEAD
 1.40.8.1  09-Jan-2008  matt sync with HEAD
 1.40.6.1  09-Dec-2007  jmcneill Sync with HEAD.
 1.41.4.1  02-Jan-2008  bouyer Sync with HEAD
 1.44.6.1  02-Jun-2008  mjf Sync with HEAD.
 1.46.2.2  04-Jun-2008  yamt sync with head
 1.46.2.1  18-May-2008  yamt sync with head.
 1.49.2.3  11-Mar-2010  yamt sync with head
 1.49.2.2  04-May-2009  yamt sync with head.
 1.49.2.1  16-May-2008  yamt sync with head.
 1.50.2.3  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.50.2.2  14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.50.2.1  10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.51.12.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.51.6.2  28-Apr-2009  skrll Sync with HEAD.
 1.51.6.1  03-Mar-2009  skrll Sync with HEAD.
 1.54.6.1  06-Jun-2011  jruoho Sync with HEAD.
 1.54.4.1  31-May-2011  rmind sync with head
 1.55.56.2  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.55.56.1  10-Jun-2019  christos Sync with HEAD
 1.55.48.2  21-Jan-2020  martin Pull up the following, requested by christos in ticket #1487:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.55.48.1  23-Feb-2019  martin Pull up following revision(s) (requested by mrg in ticket #1195):
sys/compat/sys/ipc.h: revision 1.6
sys/compat/sys/ipc.h: revision 1.7
sys/compat/sys/shm.h: revision 1.8
sys/kern/sysv_shm.c: revision 1.133
sys/compat/sys/sem.h: revision 1.7
sys/compat/linux/common/linux_ipc.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.38
sys/kern/sysv_sem.c: revision 1.96
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.28
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.29
sys/compat/linux32/common/linux32_ipccall.c: revision 1.12
sys/kern/sysv_msg.c: revision 1.73
sys/compat/sys/msg.h: revision 1.6

for sysv ipc stat operations, explicitly copy the exported parts
instead of the whole ds structure.
besides triggering a recently added assert in netbsd32, this stops
exposing kernel addresses.

copy the mode clamping to 0777 from sem to shm and msg.

while here, make sure that the compat callers to sysv_ipc clear
the contents of the compat structure before setting the result
members to ensure padding bytes are cleared.

don't set/copy _sem_base, _msg_first, _msg_last or _shm_internal.
even if used, which seems very dodgy, they leak KVAs as well.
possibly this may affect linux binaries, in particular, the
comments around _shm_internal ("XXX Oh well.") may mean apps
rely upon these but hopefully not -- the comments date back to
rev 1.1 in 1995.

the _key, _seq and _msg_cbytes members are exported as before as
i found multiple consumers of these (no less than ipcs(1), and
they appear to be useful for debugging and more.

XXX: the naming of compat functions have too many styles. there
are at least 3 different ones changed here.

fix naming errors in previous. (this file is no longer compiled, but
this fix makes the pull up more obvious, before deleting this file.)

include libkern.h or strings.h. should fix i386 build issues.
 1.55.42.2  21-Jan-2020  martin Pull up the following, requested by christos in ticket #1720:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149 (patch)
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54 (patch)

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.55.42.1  23-Feb-2019  martin Pull up following revision(s) (requested by mrg in ticket #1679):
sys/compat/sys/ipc.h: revision 1.6
sys/compat/sys/ipc.h: revision 1.7
sys/compat/sys/shm.h: revision 1.8
sys/kern/sysv_shm.c: revision 1.133
sys/compat/sys/sem.h: revision 1.7
sys/compat/linux/common/linux_ipc.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.38
sys/kern/sysv_sem.c: revision 1.96
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.28
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.29
sys/compat/linux32/common/linux32_ipccall.c: revision 1.12
sys/kern/sysv_msg.c: revision 1.73
sys/compat/sys/msg.h: revision 1.6

for sysv ipc stat operations, explicitly copy the exported parts
instead of the whole ds structure.
besides triggering a recently added assert in netbsd32, this stops
exposing kernel addresses.

copy the mode clamping to 0777 from sem to shm and msg.

while here, make sure that the compat callers to sysv_ipc clear
the contents of the compat structure before setting the result
members to ensure padding bytes are cleared.

don't set/copy _sem_base, _msg_first, _msg_last or _shm_internal.
even if used, which seems very dodgy, they leak KVAs as well.
possibly this may affect linux binaries, in particular, the
comments around _shm_internal ("XXX Oh well.") may mean apps
rely upon these but hopefully not -- the comments date back to
rev 1.1 in 1995.

the _key, _seq and _msg_cbytes members are exported as before as
i found multiple consumers of these (no less than ipcs(1), and
they appear to be useful for debugging and more.

XXX: the naming of compat functions have too many styles. there
are at least 3 different ones changed here.

fix naming errors in previous. (this file is no longer compiled, but
this fix makes the pull up more obvious, before deleting this file.)

include libkern.h or strings.h. should fix i386 build issues.
 1.55.34.1  23-Feb-2019  martin Pull up following revision(s) (requested by mrg in ticket #1679):
sys/compat/sys/ipc.h: revision 1.6
sys/compat/sys/ipc.h: revision 1.7
sys/compat/sys/shm.h: revision 1.8
sys/kern/sysv_shm.c: revision 1.133
sys/compat/sys/sem.h: revision 1.7
sys/compat/linux/common/linux_ipc.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.38
sys/kern/sysv_sem.c: revision 1.96
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.28
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.29
sys/compat/linux32/common/linux32_ipccall.c: revision 1.12
sys/kern/sysv_msg.c: revision 1.73
sys/compat/sys/msg.h: revision 1.6

for sysv ipc stat operations, explicitly copy the exported parts
instead of the whole ds structure.
besides triggering a recently added assert in netbsd32, this stops
exposing kernel addresses.

copy the mode clamping to 0777 from sem to shm and msg.

while here, make sure that the compat callers to sysv_ipc clear
the contents of the compat structure before setting the result
members to ensure padding bytes are cleared.

don't set/copy _sem_base, _msg_first, _msg_last or _shm_internal.
even if used, which seems very dodgy, they leak KVAs as well.
possibly this may affect linux binaries, in particular, the
comments around _shm_internal ("XXX Oh well.") may mean apps
rely upon these but hopefully not -- the comments date back to
rev 1.1 in 1995.

the _key, _seq and _msg_cbytes members are exported as before as
i found multiple consumers of these (no less than ipcs(1), and
they appear to be useful for debugging and more.

XXX: the naming of compat functions have too many styles. there
are at least 3 different ones changed here.

fix naming errors in previous. (this file is no longer compiled, but
this fix makes the pull up more obvious, before deleting this file.)

include libkern.h or strings.h. should fix i386 build issues.
 1.55.30.2  21-Jan-2020  martin Pull up the following, requested by christos in ticket #1720:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149 (patch)
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54 (patch)

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.55.30.1  23-Feb-2019  martin Pull up following revision(s) (requested by mrg in ticket #1679):
sys/compat/sys/ipc.h: revision 1.6
sys/compat/sys/ipc.h: revision 1.7
sys/compat/sys/shm.h: revision 1.8
sys/kern/sysv_shm.c: revision 1.133
sys/compat/sys/sem.h: revision 1.7
sys/compat/linux/common/linux_ipc.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.38
sys/kern/sysv_sem.c: revision 1.96
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.28
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.29
sys/compat/linux32/common/linux32_ipccall.c: revision 1.12
sys/kern/sysv_msg.c: revision 1.73
sys/compat/sys/msg.h: revision 1.6

for sysv ipc stat operations, explicitly copy the exported parts
instead of the whole ds structure.
besides triggering a recently added assert in netbsd32, this stops
exposing kernel addresses.

copy the mode clamping to 0777 from sem to shm and msg.

while here, make sure that the compat callers to sysv_ipc clear
the contents of the compat structure before setting the result
members to ensure padding bytes are cleared.

don't set/copy _sem_base, _msg_first, _msg_last or _shm_internal.
even if used, which seems very dodgy, they leak KVAs as well.
possibly this may affect linux binaries, in particular, the
comments around _shm_internal ("XXX Oh well.") may mean apps
rely upon these but hopefully not -- the comments date back to
rev 1.1 in 1995.

the _key, _seq and _msg_cbytes members are exported as before as
i found multiple consumers of these (no less than ipcs(1), and
they appear to be useful for debugging and more.

XXX: the naming of compat functions have too many styles. there
are at least 3 different ones changed here.

fix naming errors in previous. (this file is no longer compiled, but
this fix makes the pull up more obvious, before deleting this file.)

include libkern.h or strings.h. should fix i386 build issues.
 1.56.4.1  13-Sep-2019  martin Pull up following revision(s) (requested by maxv in ticket #194):

sys/compat/linux/common/linux_socket.c: revision 1.146
sys/compat/linux/common/linux_socket.c: revision 1.147
sys/compat/linux/common/linux_socket.c: revision 1.148
sys/compat/linux/common/linux_socket.c: revision 1.149
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.59
sys/compat/linux32/common/linux32_sysinfo.c: revision 1.8
sys/kern/sysv_shm.c: revision 1.138
sys/compat/linux/common/linux_file64.c: revision 1.61
sys/compat/linux/common/linux_file64.c: revision 1.62
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.58
sys/compat/linux32/common/linux32_dirent.c: revision 1.20
sys/compat/linux32/common/linux32_utsname.c: revision 1.10
sys/compat/linux/common/linux_termios.h: revision 1.22
sys/compat/linux32/common/linux32_termios.c: revision 1.15
sys/compat/linux32/common/linux32_misc.c: revision 1.27
sys/compat/linux32/common/linux32_ioctl.c: revision 1.14
sys/compat/linux/common/linux_statfs.h: revision 1.7
sys/compat/linux/common/linux_ipc.c: revision 1.57
sys/compat/linux/common/linux_fcntl.h: revision 1.18
sys/compat/linux/common/linux_socket.h: revision 1.24
sys/sys/shm.h: revision 1.54
sys/compat/ossaudio/ossaudio.c: revision 1.75
sys/compat/linux32/common/linux32_signal.c: revision 1.20
sys/miscfs/procfs/procfs_linux.c: revision 1.75
sys/compat/linux/common/linux_signal.c: revision 1.81
sys/compat/linux/common/linux_termios.c: revision 1.38
sys/compat/linux/common/linux_misc.c: revision 1.241
sys/compat/linux/common/linux_misc.c: revision 1.242
sys/compat/linux/common/linux_misc.c: revision 1.243
sys/compat/linux/common/linux_misc.c: revision 1.244

Fix info leaks.

Fix stupid bugs in linux_sys_shmctl(): the index could be out of bound
(page fault) and there was no proper locking.
Maybe we should just remove LINUX_SHM_STAT, like compat_linux32.

Remove printf.

When dealing with an unknown value, set -1, to prevent (harmless)
uninitialized accesses later.

Add a default case, don't call sys_ioctl() with an uninitialized 'com'
argument.

Fix error handling, returns an errno, not -1.

Put the printf under DEBUG_LINUX.


Hum, don't forget the 'pid' argument, otherwise we're not gonna go very
far.

Don't read data from userland directly. This simply does not work on any
recent x86 CPU (thanks to SMAP) and all architectures that forbid direct
access to userland from the kernel. But I guess no one noticed because no
one ever uses compat_linux, right?

Hum, don't pass an mbuf to realloc(). Inspired from copyin32_msg_control().

Fix memory leak.

I don't see the point in having this useless printf, but add a '\n' to it,
so that it at least displays useless stuff correctly.

Hum, remove incorrect assignment. Userland could have passed a smaller
namelen, and the uninitialized bytes from sb_data were being used later in
the network stack.

RSS XML Feed