From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 501DC3857BB2 for ; Thu, 11 Jan 2024 15:40:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 501DC3857BB2 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 501DC3857BB2 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704987625; cv=none; b=pj94o9vY3alugkESNNgzoXkcaFp/kmGyrvkXWPlkrKsM5vsr2o7CBt9tPSnFKsne62HmyVe0uFPSQuCKb6EFmlguIank+n99lKBqVjLcaA3repcVWnqNMvA+Eg76ByLt6oW4yUdiipxLIploOCPTdOCSOerOq9PvhR5muP6qT6I= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704987625; c=relaxed/simple; bh=PmBfx7EZTsdkEtH4dDrEYXvnY8QjyFkTxcJumKobi1E=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=dzQaTn0GDKVo8jUTrRk5KiZ6ngoM9AZDpMh3Ve3n99AXiIdA8OpdDpN6aZ1GJrhvJQQNZKBqk028GiQEHaMPSJXg6eZH166pErblqhUjiGDKkbRhKQrfXFSk1t2cOkYpEear7cT5KLEQClZ55Vjxtgg8/VqNcAxB/tJ7c7S+YDc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40BEsSWP030423; Thu, 11 Jan 2024 15:40:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=wmihRqIKFxd1w8hFbaIR3VDRoko65JvV6k7IjzgHnEM=; b=IqVMhlIdMS00Gl/MK1jWV4xdDzreTyiNiw9Sn0aRqVxl8ZDDt+13HQ+ALaZk3nsrWru3 sgNepTVtur75hDmByT5sEoig1fIbYqWwHA1Q5tlcOMvYl4OpW+eSIYHZL3rBQsyJW+wS PIIUGEW0IjAUtgNnKFbk8m3tgVLLRUzq2K7gOsU/bwDY5sXWRR6UdwSmMgej2NkkJc77 3W1zlDf1R2Eu9tQGEp+K7W7G48n8KGrnjLSpv9JWHvnt0Pq68dlnspBaA+xz+DYARxPD ezUG01wTtv6Chcbq6jBS9FlDeuTgk6qif4C4Sw3EmXb6ahJke/O3lH+shQ9rb48YX6P2 CQ== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vjjgh99st-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Jan 2024 15:40:21 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 40BFAbIA004395; Thu, 11 Jan 2024 15:40:20 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3vfjpm457w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Jan 2024 15:40:20 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 40BFeIia21758692 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Jan 2024 15:40:18 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7978B2005A; Thu, 11 Jan 2024 15:40:18 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4BDBE2004F; Thu, 11 Jan 2024 15:40:18 +0000 (GMT) Received: from [9.171.25.11] (unknown [9.171.25.11]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 11 Jan 2024 15:40:18 +0000 (GMT) Message-ID: <9540b470-7d6b-4e09-b547-b65199089899@linux.ibm.com> Date: Thu, 11 Jan 2024 16:40:18 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] resolv: Fix endless loop in __res_context_query To: Adhemerval Zanella Netto , libc-alpha@sourceware.org References: <20240111130118.1483134-1-stli@linux.ibm.com> <8bf0d13c-7480-491b-8422-27617fb94d7e@linaro.org> Content-Language: en-US From: Stefan Liebler In-Reply-To: <8bf0d13c-7480-491b-8422-27617fb94d7e@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: zfMKi0L4hnc2bIRta9iEP3xW6OuYpAFy X-Proofpoint-ORIG-GUID: zfMKi0L4hnc2bIRta9iEP3xW6OuYpAFy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-11_07,2024-01-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 lowpriorityscore=0 mlxscore=0 bulkscore=0 adultscore=0 impostorscore=0 phishscore=0 clxscore=1015 mlxlogscore=999 priorityscore=1501 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401110122 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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 11.01.24 14:27, Adhemerval Zanella Netto wrote: > > > On 11/01/24 10:01, Stefan Liebler wrote: >> Starting with commit 40c0add7d48739f5d89ebba255c1df26629a76e2 >> "resolve: Remove __res_context_query alloca usage" >> there is an endless loop in __res_context_query if >> __res_context_mkquery fails e.g. if type is invalid. Then the >> scratch buffer is resized to MAXPACKET size and it is retried again. >> >> Before the mentioned commit, it was retried only once and with the >> mentioned commit, there is no check and it retries in an endless loop. >> >> This is observable with xtest resolv/tst-resolv-qtypes which times out >> after 300s. >> >> This patch retries mkquery only once as before the mentioned commit. >> Furthermore, scratch_buffer_set_array_size is now only called with >> nelem=2 if type is T_QUERY_A_AND_AAAA (also see mentioned commit). >> The test tst-resolv-qtypes is also adjusted to verify that >> is really returning with -1 in case of an invalid type. > > Thanks for catching it. > > LGTM, thanks. > > Reviewed-by: Adhemerval Zanella > >> --- >> resolv/res_query.c | 8 +++++--- >> resolv/tst-resolv-qtypes.c | 4 ++-- >> 2 files changed, 7 insertions(+), 5 deletions(-) >> >> diff --git a/resolv/res_query.c b/resolv/res_query.c >> index 1b148a2a05..4bfba24c73 100644 >> --- a/resolv/res_query.c >> +++ b/resolv/res_query.c >> @@ -115,7 +115,7 @@ __res_context_query (struct resolv_context *ctx, const char *name, >> struct __res_state *statp = ctx->resp; >> UHEADER *hp = (UHEADER *) answer; >> UHEADER *hp2; >> - int n; >> + int n, retried = 0; > > Maybe use a bool here? Sure. Committed with a bool. Thanks, Stefan