Message ID | 20221004000657.1940145-1-siddhesh@sourceware.org |
---|---|
State | Committed |
Commit | 6e33e5c4b73cea7b8aa3de0947123db16200fb65 |
Headers |
Return-Path: <libc-alpha-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 83E493857C7D for <patchwork@sourceware.org>; Tue, 4 Oct 2022 00:07:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 83E493857C7D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1664842077; bh=hh0L3Bw7Xrrw7MZn6wkI7/+gdoz2QheJPQqDBQpz2eE=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=eUuYsn6/7S630vhIq1WTaZpKd4TAaq896vcBTLr8TUC31cNDSs2qSzX5WHsM2vhqV 38GXnKLZCCIBFHiUIZB2tvFvmThMLkmKOelM9Ufjw2ZDJ4A3oYQOqOPlmBL7/mkLUg ZUBRWb87mrl1UF0sr/BQ9IRMLbll6rhDlL35eEfQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from eastern.birch.relay.mailchannels.net (eastern.birch.relay.mailchannels.net [23.83.209.55]) by sourceware.org (Postfix) with ESMTPS id 4DB203858C74 for <libc-alpha@sourceware.org>; Tue, 4 Oct 2022 00:07:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4DB203858C74 X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 8F85B122EBC; Tue, 4 Oct 2022 00:07:20 +0000 (UTC) Received: from pdx1-sub0-mail-a305 (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id B92F6122F40; Tue, 4 Oct 2022 00:07:19 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1664842039; a=rsa-sha256; cv=none; b=NXW1ogXNft9JzdWSpvukN5ydJvpjOwGcQ4BiCL+njuQzEF7i61K2UUqmOmX+eFYJkeAMvq 378p5vW2ffYav1Xexb+ZL1yRWNj0JTzzVN9/MCuzfH6rzjHD/pCUWxYli3Nkzw1Fa8qygk H/BQSAy3BcJhmSdo+86O15hiJacMeDOgXiwgjVaG/+VnC5usnqki4+QZpq/xsMlrlCu4u6 6KmO8f7q54dkRGS50DWOScqF+93Yz7DBHDLUPbkzwliTQAWMlVX+0cIOonPC+BZoqzT+Aa mjAgye9lgyBxXH7ff5UIsXoJsONfYJPGbI0V1gloBTj2zBXqMezNVe+uY2gUrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1664842039; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=hh0L3Bw7Xrrw7MZn6wkI7/+gdoz2QheJPQqDBQpz2eE=; b=07Jxvv52VXNvta76hAHgHNm+fAlaXs49H+XcSun2Kw2WdyNLywAR1E0CABHoxywJl7pCw7 J5a9e9shFxPq5QRX129T0Nme49Wj3yOX7124pFbXW7zBAOxOPtGNuRg+HLbAi8xdamSe+q Vap3iOe1dacCd13PrI/FnVko/YUbFpbf+APZkAtWzOlIgkEqUOipHlLwcTKc7UtKHU1/uJ wk3e7ZJT7qv8fzoVL9rLpLD3I9D4qddQBNhDrcwhNY8PjD+8lkvWbSTuUROpkvwRUIN5GP z8qr/J0ATQUI2s24icX8KhB2ciX7YA2lZxiD6fEL8O8NZ1Me3L6nFjzizFqhvg== ARC-Authentication-Results: i=1; rspamd-6d4bb977-j7hpn; auth=pass smtp.auth=dreamhost smtp.mailfrom=siddhesh@sourceware.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Tasty-Interest: 473096df057daaac_1664842040195_3936977152 X-MC-Loop-Signature: 1664842040195:716206973 X-MC-Ingress-Time: 1664842040195 Received: from pdx1-sub0-mail-a305 (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.98.207.159 (trex/6.7.1); Tue, 04 Oct 2022 00:07:20 +0000 Received: from fedora.redhat.com (bras-vprn-toroon4834w-lp130-16-184-147-84-238.dsl.bell.ca [184.147.84.238]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a305 (Postfix) with ESMTPSA id 4MhJ130z7kzRW; Mon, 3 Oct 2022 17:07:19 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH] nscd: Drop local address tuple variable [BZ #29607] Date: Mon, 3 Oct 2022 20:06:57 -0400 Message-Id: <20221004000657.1940145-1-siddhesh@sourceware.org> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1173.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_SOFTFAIL, 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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list <libc-alpha.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> From: Siddhesh Poyarekar via Libc-alpha <libc-alpha@sourceware.org> Reply-To: Siddhesh Poyarekar <siddhesh@sourceware.org> Cc: =?utf-8?q?Holger_Hoffst=C3=A4tte?= <holger@applied-asynchrony.com> Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" <libc-alpha-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
nscd: Drop local address tuple variable [BZ #29607]
|
|
Checks
Context | Check | Description |
---|---|---|
dj/TryBot-apply_patch | success | Patch applied to master at the time it was sent |
dj/TryBot-32bit | success | Build for i686 |
Commit Message
Siddhesh Poyarekar
Oct. 4, 2022, 12:06 a.m. UTC
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 <holger@applied-asynchrony.com> --- 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(-)
Comments
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 <holger@applied-asynchrony.com> > --- > > 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
On 2022-10-04 02:49, Holger Hoffstätte wrote: > 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! Thank you for confirming Holger! Tested-by: Holger Hoffstätte <holger@applied-asynchrony.com>
On Mon, Oct 03, 2022 at 08:06:57PM -0400, Siddhesh Poyarekar via Libc-alpha 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. LGTM. Reviewed-by: Carlos O'Donell <carlos@redhat.com> > Resolves: BZ #29607 > Reported-by: Holger Hoffstätte <holger@applied-asynchrony.com> > --- > > 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; OK. Remove the single static struct (no longer used). > struct gaih_addrtuple *at; > while (1) > { > - at = &atmem; > + at = NULL; OK. Start with 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; OK. Remove &atmem. We set at2 to at. In all of these cases the memory is created by alloc_create_buffer() and the memory for the gaih_addrtuple comes from that buffer. We don't want to reset to &atmem sine this is no longer correct. The allocation is done at the lowest level in fct4. > at2 = at2->next) > { > ++naddrs; > -- > 2.37.2 >
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;