From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from t03.bc.larksuite.com (t03.bc.larksuite.com [209.127.231.38]) by sourceware.org (Postfix) with UTF8SMTPS id 089F73856DD0 for ; Wed, 30 Aug 2023 08:19:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 089F73856DD0 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=oss.cipunited.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=oss.cipunited.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=feishu2303200042; d=oss.cipunited.com; t=1693383542; h=from:subject:mime-version:from:date:message-id:subject:to:cc: reply-to:content-type:mime-version:in-reply-to:message-id; bh=iTbPPNmiCCdeV70c9yX5MDGRdfUtqX2g7rZYhpkHjGg=; b=RMX73sqbdpVufV8oFZi5RFPydVJhKpVmlDNHJR6xclHoqeq3kNvTDhMz2nMkY4JXSZsW0m Ok+gEGohyR3T6xODjflWkzfwwefKVH4IklWOP+rvgwZLtT+JpnGS0qgkr/6hSsBbL9y8z6 I999P3RUQIUSve1aKE4jYof1v7vVmlNG7VXdCoaDrHQfIsXEp7vY61kNS+pY04qwCy+THF tkYVpzs85tY+I6h1/VxWW8qAfa5LgrDPGr3thZrTniKKLZOT/TCpFrc9AmH0/NzMJpvkpw BOmNLSQA8wIMGezlc3e4WamF7uh7ppeqYqcweCfsZzBqBFfNBR+Bmza9j+F8HQ== To: "Joe Simmons-Talbott" , Subject: Re: [PATCH v3] mips: dl-machine-reject-phdr: Get rid of alloca. Date: Wed, 30 Aug 2023 16:18:58 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 From: "Ying Huang" Message-Id: <6313b2f1-0f39-8e02-9f96-9927787abe9f@oss.cipunited.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=99ec4eb1f739a1741d9b997197146de607259ea7c5cc2a3b4d61f9f447dd Content-Transfer-Encoding: 8bit In-Reply-To: <20230829193019.GD3849957@oak> References: <20230626131621.763381-1-josimmon@redhat.com> <20230829193019.GD3849957@oak> X-Original-From: Ying Huang X-Lms-Return-Path: Content-Language: en-US X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,HTML_MESSAGE,NICE_REPLY_A,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: --99ec4eb1f739a1741d9b997197146de607259ea7c5cc2a3b4d61f9f447dd Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 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 Thanks, Ying =E5=9C=A8 2023/8/30 03:30, Joe Simmons-Talbott via Libc-alpha =E5=86=99=E9= =81=93: > 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-mac= hine-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, u= nsigned int phnum, >> Lmid_t nsid; >> int in_abi =3D -1; >> struct abi_req in_req; >> - Elf_MIPS_ABIFlags_v0 *mips_abiflags =3D NULL; >> + Elf_MIPS_ABIFlags_v0 mips_abiflags; >> bool perfect_match =3D false; >> #if _MIPS_SIM =3D=3D _ABIO32 >> unsigned int cur_mode =3D -1; >> @@ -176,25 +176,19 @@ elf_machine_reject_phdr_p (const ElfW(Phdr) *phdr,= unsigned int phnum, >> /* Read the attributes section. */ >> if (ph !=3D NULL) >> { >> - ElfW(Addr) size =3D ph->p_filesz; >> + ElfW(Addr) size =3D sizeof (Elf_MIPS_ABIFlags_v0); >>=20=20 >> - if (ph->p_offset + size <=3D len) >> - mips_abiflags =3D (Elf_MIPS_ABIFlags_v0 *) (buf + ph->p_offset); >> - else >> - { >> - mips_abiflags =3D alloca (size); >> - __lseek (fd, ph->p_offset, SEEK_SET); >> - if (__libc_read (fd, (void *) mips_abiflags, size) !=3D 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"); >>=20=20 >> - if (__glibc_unlikely (mips_abiflags->flags2 !=3D 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) !=3D size) >> + REJECT (" unable to read PT_MIPS_ABIFLAGS\n"); >> + >> + if (__glibc_unlikely (mips_abiflags.flags2 !=3D 0)) >> + REJECT (" unknown MIPS.abiflags flags2: %u\n", mips_abiflags.flags2); >>=20=20 >> - in_abi =3D mips_abiflags->fp_abi; >> + in_abi =3D mips_abiflags.fp_abi; >> } >>=20=20 >> /* ANY is compatible with anything. */ >> --=20 >> 2.39.2 >>= --99ec4eb1f739a1741d9b997197146de607259ea7c5cc2a3b4d61f9f447dd--