public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Pranav Kant <pranavk@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc/google/grte/v5-2.27/master] CVE-2018-19591: if_nametoindex: Fix descriptor for overlong name [BZ #23927]
Date: Fri, 12 Jan 2024 23:23:40 +0000 (GMT)	[thread overview]
Message-ID: <20240112232340.6CDAF3858291@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=ac5b88042331d3a6ba0e44f8ebcc41a35ec1dab2

commit ac5b88042331d3a6ba0e44f8ebcc41a35ec1dab2
Author: Florian Weimer <fweimer@redhat.com>
Date:   Tue Nov 27 16:12:43 2018 +0100

    CVE-2018-19591: if_nametoindex: Fix descriptor for overlong name [BZ #23927]

Diff:
---
 ChangeLog                          |  8 ++++++++
 NEWS                               |  4 ++++
 sysdeps/unix/sysv/linux/if_index.c | 11 ++++++-----
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7cf21922f0..0306f0caaf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -31,6 +31,13 @@
 	* resolv/tst-resolv-nondecimal.c: Likewise.
 	* sysdeps/posix/getaddrinfo.c (gaih_inet): Call __inet_aton_exact.
 
+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-05-18  Joseph Myers  <joseph@codesourcery.com>
 
 	[BZ #22639]
@@ -38,6 +45,7 @@
 	* time/tst-y2039.c: New file.
 	* time/Makefile (tests): Add tst-y2039.
 
+
 2018-02-12  Zack Weinberg  <zackw@panix.com>
 
 	[BZ #19239]
diff --git a/NEWS b/NEWS
index 162a845cc0..46b5a2d8d8 100644
--- a/NEWS
+++ b/NEWS
@@ -32,6 +32,10 @@ Security related changes:
   addresses with arbitrary trailing characters, potentially leading to data
   or command injection issues in applications.
 
+  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.
+
   CVE-2017-18269: An SSE2-based memmove implementation for the i386
   architecture could corrupt memory.  Reported by Max Horn.
 
diff --git a/sysdeps/unix/sysv/linux/if_index.c b/sysdeps/unix/sysv/linux/if_index.c
index e3d08982d9..782fc5e175 100644
--- a/sysdeps/unix/sysv/linux/if_index.c
+++ b/sysdeps/unix/sysv/linux/if_index.c
@@ -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;

                 reply	other threads:[~2024-01-12 23:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240112232340.6CDAF3858291@sourceware.org \
    --to=pranavk@sourceware.org \
    --cc=glibc-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).