]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
CVE-2018-19591: if_nametoindex: Fix descriptor for overlong name [BZ #23927]
authorFlorian Weimer <fweimer@redhat.com>
Tue, 27 Nov 2018 15:12:43 +0000 (16:12 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Tue, 27 Nov 2018 20:26:02 +0000 (21:26 +0100)
(cherry picked from commit d527c860f5a3f0ed687bd03f0cb464612dc23408)

ChangeLog
NEWS
sysdeps/unix/sysv/linux/if_index.c

index f150dbd39ca038862bc991d2b97f8ab778b44d2d..2f1e82b61c8ef2e5a22a5e7b60cdcd55332463ba 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2018-11-27  Florian Weimer  <fweimer@redhat.com>
+
+       [BZ #23927]
+       CVE-2018-19591
+       * sysdeps/unix/sysv/linux/if_index.c (__if_nametoindex): Avoid
+       descriptor leak in case of ENODEV error.
+
 2018-11-08  Alexandra Hájková  <ahajkova@redhat.com>
 
        [BZ #17630]
diff --git a/NEWS b/NEWS
index 5fef60bc0f02ad87cb34698b51ffc9b87ee43f57..e1a23f076b5c7a421a3692d7e2c4b2b7f36d73c6 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -37,6 +37,10 @@ Security related changes:
   architecture could write beyond the target buffer, resulting in a buffer
   overflow.  Reported by Andreas Schwab.
 
+  CVE-2018-19591: A file descriptor leak in if_nametoindex can lead to a
+  denial of service due to resource exhaustion when processing getaddrinfo
+  calls with crafted host names.  Reported by Guido Vranken.
+
 The following bugs are resolved with this release:
 
   [6889] 'PWD' mentioned but not specified
@@ -97,6 +101,7 @@ The following bugs are resolved with this release:
   [23709] Fix CPU string flags for Haswell-type CPUs
   [23821] si_band in siginfo_t has wrong type long int on sparc64
   [23822] ia64 static libm.a is missing exp2f, log2f and powf symbols
+  [23927] Linux if_nametoindex() does not close descriptor (CVE-2018-19591)
 
 \f
 Version 2.27
index e3d08982d9931108b8965d07dbded44bcb2f5ff8..782fc5e1750e9eadcc2dbfff2d62828ac06973ad 100644 (file)
@@ -38,11 +38,6 @@ __if_nametoindex (const char *ifname)
   return 0;
 #else
   struct ifreq ifr;
-  int fd = __opensock ();
-
-  if (fd < 0)
-    return 0;
-
   if (strlen (ifname) >= IFNAMSIZ)
     {
       __set_errno (ENODEV);
@@ -50,6 +45,12 @@ __if_nametoindex (const char *ifname)
     }
 
   strncpy (ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
+
+  int fd = __opensock ();
+
+  if (fd < 0)
+    return 0;
+
   if (__ioctl (fd, SIOCGIFINDEX, &ifr) < 0)
     {
       int saved_errno = errno;