freebsd-nq/sys/compat/cloudabi
Mark Johnston c7902fbeae Improve handling of control message truncation.
If a recvmsg(2) or recvmmsg(2) caller doesn't provide sufficient space
for all control messages, the kernel sets MSG_CTRUNC in the message
flags to indicate truncation of the control messages.  In the case
of SCM_RIGHTS messages, however, we were failing to dispose of the
rights that had already been externalized into the recipient's file
descriptor table.  Add a new function and mbuf type to handle this
cleanup task, and use it any time we fail to copy control messages
out to the recipient.  To simplify cleanup, control message truncation
is now only performed at control message boundaries.

The change also fixes a few related bugs:
- Rights could be leaked to the recipient process if an error occurred
  while copying out a message's contents.
- We failed to set MSG_CTRUNC if the truncation occurred on a control
  message boundary, e.g., if the caller received two control messages
  and provided only the exact amount of buffer space needed for the
  first.

PR:		131876
Reviewed by:	ed (previous version)
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D16561
2018-08-07 16:36:48 +00:00
..
cloudabi_clock.c Include <sys/systm.h> to obtain the memcpy() prototype. 2017-03-24 07:09:33 +00:00
cloudabi_errno.c
cloudabi_fd.c sys/cloudabi: Avoid relying on GNU specific extensions 2018-03-07 14:47:43 +00:00
cloudabi_file.c Eliminate the overhead of gratuitous repeated reinitialization of cap_rights 2018-05-09 18:47:24 +00:00
cloudabi_futex.c Allow timed waits with relative timeouts on locks and condvars. 2018-01-04 21:57:37 +00:00
cloudabi_mem.c Upgrade to the latest sources generated from the CloudABI specification. 2017-07-26 06:57:15 +00:00
cloudabi_proc.c Catch up with changes to structure member names. 2017-01-17 22:05:52 +00:00
cloudabi_proto.h
cloudabi_random.c Catch up with changes to structure member names. 2017-01-17 22:05:52 +00:00
cloudabi_sock.c Improve handling of control message truncation. 2018-08-07 16:36:48 +00:00
cloudabi_thread.c Import the new automatically generated system call table for CloudABI. 2016-08-19 17:49:35 +00:00
cloudabi_util.h Allow timed waits with relative timeouts on locks and condvars. 2018-01-04 21:57:37 +00:00
cloudabi_vdso.c Provide the CloudABI vDSO to its executables. 2016-08-10 21:02:41 +00:00
cloudabi_vdso.lds Move the linker script from cloudabi64/ to cloudabi/. 2016-08-21 15:14:06 +00:00