git: cbf6f55e77a9 - main - x86 __vdso_gettc: add O_CLOEXEC flag to open
Konstantin Belousov
kib at FreeBSD.org
Thu Jul 29 15:01:50 UTC 2021
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=cbf6f55e77a9176572830a20804cf1d005dfea73
commit cbf6f55e77a9176572830a20804cf1d005dfea73
Author: Konstantin Belousov <kib at FreeBSD.org>
AuthorDate: 2021-07-29 01:26:38 +0000
Commit: Konstantin Belousov <kib at FreeBSD.org>
CommitDate: 2021-07-29 15:01:24 +0000
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
---
lib/libc/x86/sys/__vdso_gettc.c | 4 ++--
1 file 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,
More information about the dev-commits-src-all
mailing list