Date: Mon, 18 Mar 2013 22:59:57 +0200 From: Konstantin Belousov <kostikbel@gmail.com> To: Jilles Tjoelker <jilles@stack.nl> Cc: freebsd-hackers@freebsd.org Subject: Re: [patch] SOCK_CLOEXEC, SOCK_NONBLOCK and MSG_CMSG_CLOEXEC Message-ID: <20130318205957.GM3794@kib.kiev.ua> In-Reply-To: <20130317212353.GD65525@stack.nl> References: <20130317212353.GD65525@stack.nl>
next in thread | previous in thread | raw e-mail | index | archive | help
--YLnPAZt6hMJRJaYl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Mar 17, 2013 at 10:23:53PM +0100, Jilles Tjoelker wrote: > Here are some more modifications to allow creating file descriptors with > close-on-exec set. Like in linux/glibc, SOCK_CLOEXEC and SOCK_NONBLOCK > can be OR'ed in socket() and socketpair()'s type parameter, and > MSG_CMSG_CLOEXEC to recvmsg() makes file descriptors (SCM_RIGHTS) > atomically close-on-exec. >=20 > The numerical values for SOCK_CLOEXEC and SOCK_NONBLOCK are as in > NetBSD. MSG_CMSG_CLOEXEC is the first free bit for MSG_*. >=20 > I do not pass the SOCK_* flags to MAC because this may cause incorrect > failures and can be done later via fcntl() anyway. I expect audit to > cope with the new flags. >=20 > For MSG_CMSG_CLOEXEC, I had to change unp_externalize to take a flags > argument. This looks fine to me. The only note I have, which is not directly related to your patch, is the recvmsg(2) behaviour when the undefined flag is passed. The syscall silently ignores the flags. I think this is quite wrong, and would cause interesting (security) implications if the program using the MSG_CMSG_CLOEXEC is run on older kernel which does not interpret the flag. Might be, we should start returning EINVAL for unknown flag, despite SUSv4 not specifying the condition ? --YLnPAZt6hMJRJaYl Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iQIcBAEBAgAGBQJRR4BNAAoJEJDCuSvBvK1BYTwQAJG6hk1PePBZhmAzMo+QMc7J yfZG+dTpSeqz+/KXRz/+unuL5MgaRtirMEFKfIFk0SgXbLN0BR6OC9XdGKeBH+xZ Fc0wm4wzdmzvC79NJjV+kNBEm/lYr3zRdr2CFpkDf/YsAdP828tyTpjWqqe4bVrk slFuWBu/cUFGwlK3xRTtIpNeKFh1f5g7Xcl9eAscqK9HupbhcKVPItvhL+zoN6FF a2qBXDC7BBmNDgxExrcyZwIELkcRGa33vdVjln4foaeidkquu+RZ9AgqqcvW/S6S F0gd+GuCTv+72ZDDy3zjMm39JJqHJa7Cy/+Bq8+j2kcelvGfE2I5RWQ0dAo4GACV 1pW5ZeqPD9O4vOjUrG/jrpKokz/dnKdsumUubqN/WMZWkhKg0md0ummpI2vXi4XO MPoJZBsnTBR/tHyCJBiX+Ej8ReZSMt/ADCMD/cq4ZraE6719HU+V2wxR8kI/6ivY S/z8MQeO2wmDhLa5YOdo1NsvlKqaSEgKthay3yc3QBEJItrv1Ht9ycsVWRkh2og7 7twEBY1J2vRcBUcnD2WamJubkH4af5Vk+PhwbUzQwpOEs/J1QPASbDTbsTX3e7uS eQNKOV260i7hXNSk4VRc7qn2syvCl6UElEsrT2zVeQGAWTWK5dNHrU59YUcW/ZPI oYo/csOt11C65hWMb75f =nwSl -----END PGP SIGNATURE----- --YLnPAZt6hMJRJaYl--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130318205957.GM3794>