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.36]) by sourceware.org (Postfix) with UTF8SMTPS id 1946A3858D33 for ; Mon, 4 Sep 2023 01:12:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1946A3858D33 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=1693789966; h=from:subject:mime-version:from:date:message-id:subject:to:cc: reply-to:content-type:mime-version:in-reply-to:message-id; bh=wGUlfXiq0u9XqST+GOi8SAHUxZUCZteHUgefn/ug0gk=; b=2Q5OvbifcLdUnznBFZ/kN9l/8KqtE+kp+SZbYpnQAhsDbn8RyGFu2o/1hD7w1O9O+YFeje DNPtOV1zFk8A4aLCBNOBnLSf7fLJ0wd5jAHE4C5S0oiodLF9y1ngNbcEYLyYEtuzimulyF NkvF6ERDs2ZIRNcPOOIwprvl57BufaknkxEs4eAU7MRW4Jp+fw4Aw4AN24I29EvORF7pwY 25oynaXW/rJnn3qx1bBm7oOItqEDE4aWAL7oxXD2WJfB2gfPzFhpTdD8uG3mW1Fu9XCNQb Gb9zMEECIjNyy4yqtznFnA+CZSoziNq3BWfxWEawKuAk8r9MPXKr+NJwqCht3A== To: "Joe Simmons-Talbott" Cc: From: "Ying Huang" Message-Id: <7aeae1a1-201a-433d-0151-7ebd6c58623c@oss.cipunited.com> References: <20230626131621.763381-1-josimmon@redhat.com> <20230829193019.GD3849957@oak> <6313b2f1-0f39-8e02-9f96-9927787abe9f@oss.cipunited.com> <20230830122935.GE3849957@oak> Content-Language: en-US User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Content-Type: multipart/alternative; boundary=7765cf823e92ba42869ec66af74f61a1ee5376e74b8ff3934726f002eebe Subject: Re: [PATCH v3] mips: dl-machine-reject-phdr: Get rid of alloca. X-Lms-Return-Path: In-Reply-To: <20230830122935.GE3849957@oak> Date: Mon, 4 Sep 2023 09:12:43 +0800 Mime-Version: 1.0 X-Original-From: Ying Huang Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.8 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: --7765cf823e92ba42869ec66af74f61a1ee5376e74b8ff3934726f002eebe Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Hi Joe, =E5=9C=A8 2023/8/30 20:29, Joe Simmons-Talbott =E5=86=99=E9=81=93: > 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 a= ll 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 Yes,=C2=A0 my pleasure. And I also did test on gcc 12.2.0, binutils 2.40, mipsel-linux-gnu.=C2=A0 I= t was good, too. >> >> 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 enou= gh. >>>> >>>> Checked with build-many-glibcs.py on mips-linux-gnu >>>> --- >>>> Changes to v2: >>>> * Rather than use a scratch buffer use the mips_abiflags struct itse= lf >>>> 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-m= achine-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 =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) *phd= r, 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->flag= s2); >>>> + __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.flags= 2); >>>>=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 >>>>= --7765cf823e92ba42869ec66af74f61a1ee5376e74b8ff3934726f002eebe--