]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
getifaddrs: Don't return ifa entries with NULL names [BZ #21812]
authorDaniel Alvarez <dalvarez@redhat.com>
Fri, 29 Jun 2018 15:23:52 +0000 (17:23 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Fri, 29 Jun 2018 15:23:52 +0000 (17:23 +0200)
A lookup operation in map_newlink could turn into an insert because of
holes in the interface part of the map.  This leads to incorrectly set
the name of the interface to NULL when the interface is not present
for the address being processed (most likely because the interface was
added between the RTM_GETLINK and RTM_GETADDR calls to the kernel).
When such changes are detected by the kernel, it'll mark the dump as
"inconsistent" by setting NLM_F_DUMP_INTR flag on the next netlink
message.

This patch checks this condition and retries the whole operation.
Hopes are that next time the interface corresponding to the address
entry is present in the list and correct name is returned.

(cherry picked from commit c1f86a33ca32e26a9d6e29fc961e5ecb5e2e5eb4)

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

index 371ae547c4d9ab4b1d0eb051e38d3b3fe57a12f1..40383d9ee3a272f8c725d7ef4aa44ff878165571 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2018-06-29  Daniel Alvarez  <dalvarez@redhat.com>
+           Jakub Sitnicki  <jkbs@redhat.com>
+
+       [BZ #21812]
+       * sysdeps/unix/sysv/linux/ifaddrs.c (getifaddrs_internal): Retry
+       on NLM_F_DUMP_INTR.
+
 2018-06-28  Florian Weimer  <fweimer@redhat.com>
 
        [BZ #23349]
diff --git a/NEWS b/NEWS
index f6e33734c8e6b57676fd0a0ce1810d438f1ac1e0..501d97bc7af00326eba1370592ba77e5fca39ce2 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -45,6 +45,7 @@ The following bugs are resolved with this release:
   [18018] Additional $ORIGIN handling issues (CVE-2011-0536)
   [20419] files with large allocated notes crash in open_verify
   [21269] i386 sigaction sa_restorer handling is wrong
+  [21812] getifaddrs: Don't return ifa entries with NULL names
   [21942] _dl_dst_substitute incorrectly handles $ORIGIN: with AT_SECURE=1
   [22342] NSCD not properly caching netgroup
   [22638] sparc: static binaries are broken if glibc is built by gcc
index 32381f54e4e0e10c42c47aed0ebeb1df03bf19af..ac0e1e5738f3a24fd576306a58c0c65e2e018d9b 100644 (file)
@@ -370,6 +370,14 @@ getifaddrs_internal (struct ifaddrs **ifap)
          if ((pid_t) nlh->nlmsg_pid != nh.pid || nlh->nlmsg_seq != nlp->seq)
            continue;
 
+         /* If the dump got interrupted, we can't rely on the results
+            so try again. */
+         if (nlh->nlmsg_flags & NLM_F_DUMP_INTR)
+           {
+             result = -EAGAIN;
+             goto exit_free;
+           }
+
          if (nlh->nlmsg_type == NLMSG_DONE)
            break;              /* ok */