From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id BBC4A3858D33 for ; Wed, 18 Oct 2023 13:31:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BBC4A3858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BBC4A3858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697635921; cv=none; b=GjsKOS13bADJnUgfpmk+6oPlJcrHb9M50g/Akek/QPoq/HXgg8HWO549Y3+YmQRT1YJ7YLdL8mOhWJLJgi4VKRpViFel1zis+7GdLbg3/O10v9tdK5MyAFtRBwvR+d36Kys4Y7gJ6SMFe4mhpV289c2R4Evi43jmrhEG1AogLMY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697635921; c=relaxed/simple; bh=JDKDPyARksCj5HhY1CyYGpZvurAoY8IzQj/S05TzgAI=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=QkAk3umbJ7AkPV4mmWjnfEtNkWhcdzy4tNg8TgthN2FWdDzuCCnDZ+DBDCMXrTX2/Aukzlbc599Bbund9OG2aK3/560r1g0wT0pPrhQ8suqOAgull7j1+5tCHHaQqk+dOmU7q4GzgGHgOMAgsiGFvXGCdYHIX8Epj2xvCGHNHm0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697635916; 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: in-reply-to:in-reply-to:references:references; bh=D0woZlnhkXLG2xi0Qq2y+heLPJTGbnXRzvDbXZzL31E=; b=YBgRQSpI0SUCT2EDNRFgQkF7zlPRmqkNa0ATdS8vSfmIH1agBPCbhTw1ihEL6uZpvH1lWX Z6vwfyULyOJoIjIKE9AmHtL7Yp5mViQiwUZoqmvrpryiSHljvzzZIY/iMYbLpb1pVejAx3 e/MP6GkAjKmKuyqePkISOvjbi6K9vwM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-480-W8zipsldOy6qsj9lxBMyQg-1; Wed, 18 Oct 2023 09:31:54 -0400 X-MC-Unique: W8zipsldOy6qsj9lxBMyQg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4117C1039419; Wed, 18 Oct 2023 13:31:53 +0000 (UTC) Received: from oak (unknown [10.22.34.133]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 261062026D4C; Wed, 18 Oct 2023 13:31:53 +0000 (UTC) Date: Wed, 18 Oct 2023 09:31:51 -0400 From: Joe Simmons-Talbott To: Adhemerval Zanella Netto Cc: libc-alpha@sourceware.org Subject: Re: [PATCH] elf: dl-load: Get rid of alloca usage. Message-ID: <20231018133151.GT4098455@oak> References: <20231002132404.249890-1-josimmon@redhat.com> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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 Tue, Oct 17, 2023 at 02:50:41PM -0300, Adhemerval Zanella Netto wrote: > > > On 02/10/23 10:24, Joe Simmons-Talbott wrote: > > Replace alloca usage with scratch_buffers. Change the sematics of > > is_trusted_path_normalize to return 1, 0, or -1 on error. > > --- > > elf/dl-load.c | 72 ++++++++++++++++++++++++++++++++++++++++++--------- > > 1 file changed, 60 insertions(+), 12 deletions(-) > > > > diff --git a/elf/dl-load.c b/elf/dl-load.c > > index 2923b1141d..c8e135b6e5 100644 > > --- a/elf/dl-load.c > > +++ b/elf/dl-load.c > > @@ -21,6 +21,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -124,14 +125,21 @@ static const size_t system_dirs_len[] = > > }; > > #define nsystem_dirs_len array_length (system_dirs_len) > > > > -static bool > > +static int > > The main problem is _dl_dst_substitute, which calls is_trusted_path_normalize, > is not suppose to fail. The expand_dynamic_string_token does handle null, > but fillin_rpath will just ignore the entry. I think it should > _dl_signal_error (ENOMEM, ...). > > Same for expand_dst macro, which does not expect to _dl_dst_substitute fail > with memory allocation. > > So I think it would be better to split the patch to first only remove the > alloca from is_trusted_path_normalize, add memory allocation checks on > _dl_dst_substitute to return NULL if is_trusted_path_normalize fails to > allocate memory, and add NULL checks for _dl_dst_substitute callers as well. I've posted a v2 which hopefully does as you've suggested. I also added the scratch_buffer_free that was overlooked. Thanks for your review. Thanks, Joe