From patchwork Fri Jun 15 13:29:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Alvarez Sanchez X-Patchwork-Id: 929942 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-93284-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="iVj99Bez"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 416hDN6LPzz9s37 for ; Fri, 15 Jun 2018 23:29:39 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; q=dns; s= default; b=ybic7FaOm82brqyz4R+AjTJxVx/uJrCk9RREK0l3/lRmnRhdsEw03 0X1NcIG+Im+iOQbJ9uxyViTuHa7KK96ZxtjXKyI7UdjEjEHyp/IlLHmtgJP1v7JZ g5pMpUr7nn9miuNrKLvfsN/pKiXKbJpsWKKZycCTKqDtY6lELP0zA8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; s=default; bh=L3Ucyt1obp+v9rEay4qML4oBTlI=; b=iVj99BezyZ+IT1xDFeYbnHCqxL3D Z1A4iUVkm37qKfv3RPnTekryocLlOQVirCo6MvKWxOUFnppT0uHurs9yK8gnnTmv Sni/iWb7BNfmgPLYLEDUXwvQLI/mtSgUuuHNFj3rEmclgxQjrl8ZJXQ44KNZB7OI XcxFYQIn5gDGQQQ= Received: (qmail 58545 invoked by alias); 15 Jun 2018 13:29:34 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 58536 invoked by uid 89); 15 Jun 2018 13:29:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=holes, ifa, itll X-HELO: mx1.redhat.com From: Daniel Alvarez To: libc-alpha@sourceware.org Cc: Daniel Alvarez , Jakub Sitnicki Subject: [PATCH] [BZ #21812] getifaddrs() Don't return ifa entries with NULL names Date: Fri, 15 Jun 2018 15:29:15 +0200 Message-Id: <20180615132915.83940-1-dalvarez@redhat.com> Due to bug 21812, a lookup operation in map_newlink() turns out 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. Signed-off-by: Daniel Alvarez Signed-off-by: Jakub Sitnicki --- sysdeps/unix/sysv/linux/ifaddrs.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sysdeps/unix/sysv/linux/ifaddrs.c b/sysdeps/unix/sysv/linux/ifaddrs.c index 32381f54e4..5659c9605b 100644 --- a/sysdeps/unix/sysv/linux/ifaddrs.c +++ b/sysdeps/unix/sysv/linux/ifaddrs.c @@ -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 relay 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 */