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.129.124]) by sourceware.org (Postfix) with ESMTPS id 4DB813858D28 for ; Wed, 30 Aug 2023 12:29:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4DB813858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693398578; 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: in-reply-to:in-reply-to:references:references; bh=rzsu6uAnBsnDsHuzPTjXTrSrE+vmEWr3qSvgi8GKG6g=; b=DLWn+rKMJhymfkrmfl0yF92bdAsA5v9aU1ekdNE15hQjpQmkPXtwGO0Qj+TRMGzPqgaGo1 8D+xtAwwapqbeqGDnuX3d16+OVdPBuAMrCFU42h3+uEDbwLO3tPZ3wH0ubfs16BneFViWg 0iowGR+iUS+qLmdkkS2AZkQ7K7HxffI= 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-487-hXhdAMgzOeKL_aoGZctptg-1; Wed, 30 Aug 2023 08:29:37 -0400 X-MC-Unique: hXhdAMgzOeKL_aoGZctptg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 025408028B2; Wed, 30 Aug 2023 12:29:37 +0000 (UTC) Received: from oak (unknown [10.22.33.147]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D45C3140E96E; Wed, 30 Aug 2023 12:29:36 +0000 (UTC) Date: Wed, 30 Aug 2023 08:29:35 -0400 From: Joe Simmons-Talbott To: Ying Huang Cc: libc-alpha@sourceware.org Subject: Re: [PATCH v3] mips: dl-machine-reject-phdr: Get rid of alloca. Message-ID: <20230830122935.GE3849957@oak> References: <20230626131621.763381-1-josimmon@redhat.com> <20230829193019.GD3849957@oak> <6313b2f1-0f39-8e02-9f96-9927787abe9f@oss.cipunited.com> MIME-Version: 1.0 In-Reply-To: <6313b2f1-0f39-8e02-9f96-9927787abe9f@oss.cipunited.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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_H4,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 Wed, Aug 30, 2023 at 04:18:58PM +0800, Ying Huang wrote: > Hi, > > I have tested this patch on my lab, the resutls of make and make check all were good. > > And make check did not introduce new XFAILS. > > The environment is: > > gcc 12.2.0, binutils 2.40, mips64el-linux-gnuabi64 Thank you for testing. May I add a Tested-by: line? Thanks, Joe > > > Thanks, > > Ying > > > 在 2023/8/30 03:30, Joe Simmons-Talbott via Libc-alpha 写道: > > Ping. > > > > On Mon, Jun 26, 2023 at 09:16:21AM -0400, Joe Simmons-Talbott wrote: > >> Read directly into the mips_abiflags struct rather than reading the > >> entire segment and using alloca when the passed buffer is not big enough. > >> > >> Checked with build-many-glibcs.py on mips-linux-gnu > >> --- > >> Changes to v2: > >> * Rather than use a scratch buffer use the mips_abiflags struct itself > >> for reading since we're now just reading that much data and not the > >> whole segment. > >> > >> sysdeps/mips/dl-machine-reject-phdr.h | 26 ++++++++++---------------- > >> 1 file changed, 10 insertions(+), 16 deletions(-) > >> > >> diff --git a/sysdeps/mips/dl-machine-reject-phdr.h b/sysdeps/mips/dl-machine-reject-phdr.h > >> index 104b590661..b784697fc1 100644 > >> --- a/sysdeps/mips/dl-machine-reject-phdr.h > >> +++ b/sysdeps/mips/dl-machine-reject-phdr.h > >> @@ -161,7 +161,7 @@ elf_machine_reject_phdr_p (const ElfW(Phdr) *phdr, unsigned int phnum, > >> Lmid_t nsid; > >> int in_abi = -1; > >> struct abi_req in_req; > >> - Elf_MIPS_ABIFlags_v0 *mips_abiflags = NULL; > >> + Elf_MIPS_ABIFlags_v0 mips_abiflags; > >> bool perfect_match = false; > >> #if _MIPS_SIM == _ABIO32 > >> unsigned int cur_mode = -1; > >> @@ -176,25 +176,19 @@ elf_machine_reject_phdr_p (const ElfW(Phdr) *phdr, unsigned int phnum, > >> /* Read the attributes section. */ > >> if (ph != NULL) > >> { > >> - ElfW(Addr) size = ph->p_filesz; > >> + ElfW(Addr) size = sizeof (Elf_MIPS_ABIFlags_v0); > >> > >> - if (ph->p_offset + size <= len) > >> - mips_abiflags = (Elf_MIPS_ABIFlags_v0 *) (buf + ph->p_offset); > >> - else > >> - { > >> - mips_abiflags = alloca (size); > >> - __lseek (fd, ph->p_offset, SEEK_SET); > >> - if (__libc_read (fd, (void *) mips_abiflags, size) != size) > >> - REJECT (" unable to read PT_MIPS_ABIFLAGS\n"); > >> - } > >> - > >> - if (size < sizeof (Elf_MIPS_ABIFlags_v0)) > >> + if (ph->p_filesz < size) > >> REJECT (" contains malformed PT_MIPS_ABIFLAGS\n"); > >> > >> - if (__glibc_unlikely (mips_abiflags->flags2 != 0)) > >> - REJECT (" unknown MIPS.abiflags flags2: %u\n", mips_abiflags->flags2); > >> + __lseek (fd, ph->p_offset, SEEK_SET); > >> + if (__libc_read (fd, (void *) &mips_abiflags, size) != size) > >> + REJECT (" unable to read PT_MIPS_ABIFLAGS\n"); > >> + > >> + if (__glibc_unlikely (mips_abiflags.flags2 != 0)) > >> + REJECT (" unknown MIPS.abiflags flags2: %u\n", mips_abiflags.flags2); > >> > >> - in_abi = mips_abiflags->fp_abi; > >> + in_abi = mips_abiflags.fp_abi; > >> } > >> > >> /* ANY is compatible with anything. */ > >> -- > >> 2.39.2 > >>