freebsd-dev/sys/compat/freebsd32
Jessica Clarke 7b673a2c73 freebsd32: Make sendmsg match native ABI for unpadded final control message
The API says that CMSG_SPACE should be used for msg_controllen, but in
practice the native ABI allows you to only use CMSG_LEN for the final
(typically only) control message, and real-world software does this,
including Wayland. For freebsd32, this is in practice mostly harmless,
since control messages are generally used to carry file descriptors,
which are already 4 bytes in size and thus no padding is needed, but
they can carry other quantities that may not result in an aligned
length. This was discovered after CheriBSD's freebsd64 equivalent was
updated to match the freebsd32 implementation, as that uses 8 byte
alignment which does break the file descriptor use case, and thus
Wayland.

This used to be addressed by aligning buflen before the first iteration,
but that allowed unwanted invalid inputs and was lost in 1b1428dcc8,
with no safer equivalent put in its place.

Reviewed by:	brooks, kib, markj
Obtained from:	CheriBSD
Fixes:		1b1428dcc8 ("Fix a TOCTOU vulnerability in freebsd32_copyin_control().")
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D36554
2022-09-15 17:16:22 +01:00
..
freebsd32_abort2.c freebsd32: add real abort2 2021-11-17 20:12:25 +00:00
freebsd32_capability.c fd: rename fget*_locked to fget*_noref 2022-02-22 18:53:43 +00:00
freebsd32_ioctl.c sysent: Get rid of bogus sys/sysent.h include. 2022-05-28 20:52:17 +03:00
freebsd32_ioctl.h Move 32-bit compat support for FIODGNAME to the right place. 2018-10-26 17:59:25 +00:00
freebsd32_ipc.h freebsd32: Fix layout of struct shmid_kernel32. 2022-01-18 10:42:21 -08:00
freebsd32_misc.c freebsd32: Make sendmsg match native ABI for unpadded final control message 2022-09-15 17:16:22 +01:00
freebsd32_misc.h Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights 2021-08-08 10:42:24 -04:00
freebsd32_proto.h sysent: regen for syscallarg_t 2022-03-28 19:43:03 +01:00
freebsd32_signal.h sys/compat: Use C99 fixed-width integer types. 2021-12-28 09:41:33 -08:00
freebsd32_syscall.h Regen 2021-12-09 02:49:10 +02:00
freebsd32_syscalls.c Regen 2021-12-09 02:49:10 +02:00
freebsd32_sysent.c sysent: regen after 52a1d90c8b, posix_fadvise in capmode 2022-04-14 15:17:36 -04:00
freebsd32_systrace_args.c Regen 2021-12-09 02:49:10 +02:00
freebsd32_util.h sys/compat: Use C99 fixed-width integer types. 2021-12-28 09:41:33 -08:00
freebsd32.h Implement shared page address randomization 2022-07-18 16:27:37 +02:00
Makefile freebsd32: generate from sys/kern/syscalls.master 2021-11-22 22:36:58 +00:00
syscalls.conf freebsd32: generate from sys/kern/syscalls.master 2021-11-22 22:36:58 +00:00