From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) by sourceware.org (Postfix) with ESMTPS id BEB693858C52 for ; Thu, 14 Sep 2023 17:36:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BEB693858C52 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-1d4e0c29028so615106fac.3 for ; Thu, 14 Sep 2023 10:36:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694712972; x=1695317772; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:organization:from:references :to:content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=lq7BisVZ670WVUKLoAsRYgx+Ts6QSccA06p44Ej3x3I=; b=POt0QZyGcijKnR3ylJLU3MlodySK6jExWoTZcetP6g1XzgBPvJM5SXO0Q7NwNz5zmX 7HfiUoUSajTInUdbAYQ/o7zH3rSt8cAI7kCHu6Ip9Hmbm40SWrLHMzB/SANGh0R790UD 948f9JCqdb1O8EkBz2mrWSbN63fzdFPItkvCdUScCDbiPqQjbMD9B8qtjclrM6r+aIhW hn7YRmLyjpaZ/dNZxhRBthvzpIGfk/0NRSshwP8XR1pZVM2YTnyEMfJCL8zF3NIE+IKo csveXKZegv1wQb0ORxl02tpybaEkdypwzSZAt5tHLkWPs+NUGtdbQPg8WjeviB8SKSor pYsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694712972; x=1695317772; h=content-transfer-encoding:in-reply-to:organization:from:references :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lq7BisVZ670WVUKLoAsRYgx+Ts6QSccA06p44Ej3x3I=; b=m+tSbt1OynmTuTWVw2VXqeO25TK9BFDpveneMfXYOtZt8wM2je03W/UH+aEFmPc0vU bsPQKzmh+yMv1rOT1wzOup540ieFTxvN7/yhRPu5bcKgBUkO9x9ciez1fSIFJPwjUoYT 53aaeAg7ZelUruvqMHBDq7crmhFPxxeEkMI2HrfgtwgEL7fxSmZ266FOOXE08OxHymdU H1ugxr958v6AIPRH6RmtmH684DWWcuFVEc22x8Q0qDcuQB7jslx3kPFu2UDJ4nPMx+3i CkKkaKchyfqC+x6rP5UkfGk9dDXdK/RBbTI1UNOtVi6pm+bijAwh3V5QiYMPNZOTooZ9 oXxQ== X-Gm-Message-State: AOJu0YwxgeyWUCKNzUkWNgmIOw/t6ZXJA6e5aKNuBlVu56fqA44JvX/n eNZ1xet5apBkcucNc3zfhd0omQ== X-Google-Smtp-Source: AGHT+IGVoWz2yfx5K+XNobGNVaHloZa4Ond7WoRueMBF6nePgp6VI/84Dsyuvyk+qk7j42lt8VZMnA== X-Received: by 2002:a05:6870:184e:b0:1d5:8e6c:1794 with SMTP id u14-20020a056870184e00b001d58e6c1794mr6316114oaf.58.1694712972594; Thu, 14 Sep 2023 10:36:12 -0700 (PDT) Received: from ?IPV6:2804:1b3:a7c0:91cb:8813:a8ad:85d6:b2a8? ([2804:1b3:a7c0:91cb:8813:a8ad:85d6:b2a8]) by smtp.gmail.com with ESMTPSA id ed23-20020a056870b79700b001cd14c60b35sm1017473oab.5.2023.09.14.10.36.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 Sep 2023 10:36:11 -0700 (PDT) Message-ID: <8a52dd0c-ae69-cd01-c2c1-01523d7f1543@linaro.org> Date: Thu, 14 Sep 2023 14:36:09 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: Re: [PATCH] resolv/res_query: Add note indicating that alloca usage is safe. Content-Language: en-US To: Joe Simmons-Talbott , libc-alpha@sourceware.org References: <20230705181341.1470594-1-josimmon@redhat.com> <20230828145825.GX3849957@oak> <20230914150425.GQ3849957@oak> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <20230914150425.GQ3849957@oak> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,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 14/09/23 12:04, Joe Simmons-Talbott wrote: > Ping. > > On Mon, Aug 28, 2023 at 10:58:25AM -0400, Joe Simmons-Talbott via Libc-alpha wrote: >> On Mon, Aug 28, 2023 at 10:50:21AM -0300, Adhemerval Zanella Netto wrote: >>> >>> >>> On 05/07/23 15:13, Joe Simmons-Talbott via Libc-alpha wrote: >>>> The buffer size is small (< 1024) and fixed sized so alloca is safe >>>> here. >>>> --- >>>> resolv/res_query.c | 1 + >>>> 1 file changed, 1 insertion(+) >>>> >>>> diff --git a/resolv/res_query.c b/resolv/res_query.c >>>> index 049de91b95..0e0e7be624 100644 >>>> --- a/resolv/res_query.c >>>> +++ b/resolv/res_query.c >>>> @@ -117,6 +117,7 @@ __res_context_query (struct resolv_context *ctx, const char *name, >>>> int n, use_malloc = 0; >>>> >>>> size_t bufsize = (type == T_QUERY_A_AND_AAAA ? 2 : 1) * QUERYSIZE; >>>> + /* alloca is safe here since bufsize < 1024 and fixed sized. */ >>>> u_char *buf = alloca (bufsize); >>> >>> The bufsize on current Linux build is: >>> >>> size_t bufsize = (type == 439963904 ? 2 : 1) * (12 + 4 + 255 + 1); >>> >>> So with upper bound as 544 (2 * (12 + 4 + 255 + 1)). However, it might >>> increase to 2 * PACKETSIZE later with malloc. This is exactly the scenarion >>> scratch_buffer was created, so maybe we should use it. Below a complete >>> untested patch: >> >> Thanks for the patch. I've tested it with 'make check' on >> x86_64-linux-gnu. I'm not sure how to handle this and don't feel >> comfortable submitting it on your behalf or as my own work but am happy >> to give a Reviewed-by once there's a commit message. I had forgotten about this, I will send a proper patch.