aboutsummaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2021-07-29 01:26:38 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2021-07-29 15:01:24 +0000
commitcbf6f55e77a9176572830a20804cf1d005dfea73 (patch)
tree756f06231bf0df48af2f6173e86927978677adaa /lib/libc
parent4b136ef259cefedc9b6404afc09138aeb8acbd91 (diff)
downloadsrc-cbf6f55e77a9176572830a20804cf1d005dfea73.tar.gz
src-cbf6f55e77a9176572830a20804cf1d005dfea73.zip
x86 __vdso_gettc: add O_CLOEXEC flag to open
of the /dev/hpet and /dev/hv_tsc devices, to not leak internal libc filedescriptors on exec. Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31344
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/x86/sys/__vdso_gettc.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libc/x86/sys/__vdso_gettc.c b/lib/libc/x86/sys/__vdso_gettc.c
index 7a64f2a0b556..ab10943c811b 100644
--- a/lib/libc/x86/sys/__vdso_gettc.c
+++ b/lib/libc/x86/sys/__vdso_gettc.c
@@ -230,7 +230,7 @@ __vdso_init_hpet(uint32_t u)
* triggering trap_enocap on the device open by absolute path.
*/
if ((cap_getmode(&mode) == 0 && mode != 0) ||
- (fd = _open(devname, O_RDONLY)) == -1) {
+ (fd = _open(devname, O_RDONLY | O_CLOEXEC)) == -1) {
/* Prevent the caller from re-entering. */
atomic_cmpset_rel_ptr((volatile uintptr_t *)&hpet_dev_map[u],
(uintptr_t)old_map, (uintptr_t)MAP_FAILED);
@@ -266,7 +266,7 @@ __vdso_init_hyperv_tsc(void)
if (cap_getmode(&mode) == 0 && mode != 0)
goto fail;
- fd = _open(HYPERV_REFTSC_DEVPATH, O_RDONLY);
+ fd = _open(HYPERV_REFTSC_DEVPATH, O_RDONLY | O_CLOEXEC);
if (fd < 0)
goto fail;
hyperv_ref_tsc = mmap(NULL, sizeof(*hyperv_ref_tsc), PROT_READ,