public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/26791] New: Missing O_CLOEXEC in sysconf.c
@ 2020-10-26 16:04 max at maxfragg dot de
  2020-11-11 10:32 ` [Bug libc/26791] " arjun.is at lostca dot se
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: max at maxfragg dot de @ 2020-10-26 16:04 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=26791

            Bug ID: 26791
           Summary: Missing O_CLOEXEC in sysconf.c
           Product: glibc
           Version: 2.34
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: max at maxfragg dot de
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

if sysconf is used in multithreaded processes, various filedescriptors may leak
due to missing O_CLOEXEC. Bug present in current head and at least all recent
glibc-versions.

diff --git a/sysdeps/unix/sysv/linux/sysconf.c
b/sysdeps/unix/sysv/linux/sysconf.c
index 7958a74..783938a 100644
--- a/sysdeps/unix/sysv/linux/sysconf.c
+++ b/sysdeps/unix/sysv/linux/sysconf.c
@@ -81,7 +81,7 @@ __sysconf (int name)

   if (procfname != NULL)
     {
-      int fd = __open_nocancel (procfname, O_RDONLY);
+      int fd = __open_nocancel (procfname, O_RDONLY|O_CLOEXEC);
       if (fd != -1)
        {
          /* This is more than enough, the file contains a single integer.  */

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-11-11 12:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-26 16:04 [Bug libc/26791] New: Missing O_CLOEXEC in sysconf.c max at maxfragg dot de
2020-11-11 10:32 ` [Bug libc/26791] " arjun.is at lostca dot se
2020-11-11 12:32 ` arjun.is at lostca dot se
2020-11-11 12:33 ` arjun.is at lostca dot se
2020-11-11 12:37 ` arjun.is at lostca dot se

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).