From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.itouring.de (mail.itouring.de [IPv6:2a01:4f8:a0:4463::2]) by sourceware.org (Postfix) with ESMTPS id 146183858D1E; Tue, 4 Oct 2022 06:49:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 146183858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=applied-asynchrony.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=applied-asynchrony.com Received: from tux.applied-asynchrony.com (p5ddd7cb4.dip0.t-ipconnect.de [93.221.124.180]) by mail.itouring.de (Postfix) with ESMTPSA id 92FD2103762; Tue, 4 Oct 2022 08:49:53 +0200 (CEST) Received: from [192.168.100.221] (hho.applied-asynchrony.com [192.168.100.221]) by tux.applied-asynchrony.com (Postfix) with ESMTP id 1D87DEEBB2B; Tue, 4 Oct 2022 08:49:53 +0200 (CEST) Subject: Re: [PATCH] nscd: Drop local address tuple variable [BZ #29607] To: Siddhesh Poyarekar , libc-alpha@sourceware.org References: <20221004000657.1940145-1-siddhesh@sourceware.org> From: =?UTF-8?Q?Holger_Hoffst=c3=a4tte?= Organization: Applied Asynchrony, Inc. Message-ID: Date: Tue, 4 Oct 2022 08:49:53 +0200 MIME-Version: 1.0 In-Reply-To: <20221004000657.1940145-1-siddhesh@sourceware.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_STATUS,RCVD_IN_BARRACUDACENTRAL,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 2022-10-04 02:06, Siddhesh Poyarekar wrote: > When a request needs to be resent (e.g. due to insufficient buffer > space), the references to subsequent tuples in the local variable are > stale and should not be used. This used to work by accident before, but > since 1d495912a it no longer does. Instead of trying to reset it, just > let gethostbyname4_r write into TUMPBUF6 for us, thus maintaining a > consistent state at all times. This is now consistent with what is done > in gaih_inet for getaddrinfo. > > Resolves: BZ #29607 > Reported-by: Holger Hoffstätte > --- > > Tested on x86_64 with Fedora and nscd enabled. Testing with other > distributions would be really appreciated! > > Thanks, > Sid > > > nscd/aicache.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/nscd/aicache.c b/nscd/aicache.c > index 51e793199f..e0baed170b 100644 > --- a/nscd/aicache.c > +++ b/nscd/aicache.c > @@ -110,11 +110,10 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req, > "gethostbyname4_r"); > if (fct4 != NULL) > { > - struct gaih_addrtuple atmem; > struct gaih_addrtuple *at; > while (1) > { > - at = &atmem; > + at = NULL; > rc6 = 0; > herrno = 0; > status[1] = DL_CALL_FCT (fct4, (key, &at, > @@ -137,7 +136,7 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req, > goto next_nip; > > /* We found the data. Count the addresses and the size. */ > - for (const struct gaih_addrtuple *at2 = at = &atmem; at2 != NULL; > + for (const struct gaih_addrtuple *at2 = at; at2 != NULL; > at2 = at2->next) > { > ++naddrs; > Hello Siddesh, I am happy to report that this seems to be working fine and fixes the reported bug; there haven't been any nscd crashes for a few hours now on any of my machines. Thanks! Holger