Page MenuHomeFreeBSD

x86 __vdso_gettc: add O_CLOEXEC flag to open
ClosedPublic

Authored by kib on Jul 29 2021, 1:35 AM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 15 2024, 6:22 PM
Unknown Object (File)
Dec 22 2023, 10:31 PM
Unknown Object (File)
Dec 18 2023, 10:14 PM
Unknown Object (File)
Dec 12 2023, 2:21 PM
Unknown Object (File)
Nov 14 2023, 8:28 AM
Unknown Object (File)
Nov 6 2023, 1:00 AM
Unknown Object (File)
Oct 13 2023, 7:23 AM
Unknown Object (File)
Oct 4 2023, 11:58 PM
Subscribers
None

Details

Summary

of the /dev/hpet and /dev/hv_tsc devices, to not leak internal libc filedescriptors on exec.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.Jul 29 2021, 1:35 AM
kib created this revision.

BTW, there are a couple of _opens() in the locale code which should use O_CLOEXEC as well:

diff --git a/lib/libc/locale/collate.c b/lib/libc/locale/collate.c
index c992d2299ab7..7afb2043e6a4 100644
--- a/lib/libc/locale/collate.c
+++ b/lib/libc/locale/collate.c
@@ -131,7 +131,7 @@ __collate_load_tables_l(const char *encoding, struct xlocale_collate *table)
        if (asprintf(&buf, "%s/%s/LC_COLLATE", _PathLocale, encoding) == -1)
                return (_LDP_ERROR);
 
-       if ((fd = _open(buf, O_RDONLY)) < 0) {
+       if ((fd = _open(buf, O_RDONLY | O_CLOEXEC)) < 0) {
                free(buf);
                return (_LDP_ERROR);
        }
diff --git a/lib/libc/locale/rune.c b/lib/libc/locale/rune.c
index b7334636f654..ce2095763eba 100644
--- a/lib/libc/locale/rune.c
+++ b/lib/libc/locale/rune.c
@@ -74,7 +74,7 @@ _Read_RuneMagi(const char *fname)
        int runetype_ext_len = 0;
        int fd;
 
-       if ((fd = _open(fname, O_RDONLY)) < 0) {
+       if ((fd = _open(fname, O_RDONLY | O_CLOEXEC)) < 0) {
                errno = EINVAL;
                return (NULL);
        }
This revision is now accepted and ready to land.Jul 29 2021, 11:47 AM

BTW, there are a couple of _opens() in the locale code which should use O_CLOEXEC as well:

This looks fine, but should be a separate change (yours).

This revision was automatically updated to reflect the committed changes.