* [PATCH v3] mips: dl-machine-reject-phdr: Get rid of alloca. @ 2023-06-26 13:16 Joe Simmons-Talbott 2023-08-29 19:30 ` Joe Simmons-Talbott 2023-10-02 12:13 ` Adhemerval Zanella Netto 0 siblings, 2 replies; 9+ messages in thread From: Joe Simmons-Talbott @ 2023-06-26 13:16 UTC (permalink / raw) To: libc-alpha; +Cc: Joe Simmons-Talbott 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3] mips: dl-machine-reject-phdr: Get rid of alloca. 2023-06-26 13:16 [PATCH v3] mips: dl-machine-reject-phdr: Get rid of alloca Joe Simmons-Talbott @ 2023-08-29 19:30 ` Joe Simmons-Talbott 2023-08-30 8:18 ` Ying Huang 2023-09-07 12:25 ` Joe Simmons-Talbott 2023-10-02 12:13 ` Adhemerval Zanella Netto 1 sibling, 2 replies; 9+ messages in thread From: Joe Simmons-Talbott @ 2023-08-29 19:30 UTC (permalink / raw) To: 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 > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3] mips: dl-machine-reject-phdr: Get rid of alloca. 2023-08-29 19:30 ` Joe Simmons-Talbott @ 2023-08-30 8:18 ` Ying Huang 2023-08-30 12:29 ` Joe Simmons-Talbott 2023-09-07 12:25 ` Joe Simmons-Talbott 1 sibling, 1 reply; 9+ messages in thread From: Ying Huang @ 2023-08-30 8:18 UTC (permalink / raw) To: Joe Simmons-Talbott, libc-alpha [-- Attachment #1: Type: text/plain, Size: 2975 bytes --] 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 在 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 >> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3] mips: dl-machine-reject-phdr: Get rid of alloca. 2023-08-30 8:18 ` Ying Huang @ 2023-08-30 12:29 ` Joe Simmons-Talbott 2023-09-04 1:12 ` Ying Huang 0 siblings, 1 reply; 9+ messages in thread From: Joe Simmons-Talbott @ 2023-08-30 12:29 UTC (permalink / raw) To: Ying Huang; +Cc: libc-alpha 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 > >> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3] mips: dl-machine-reject-phdr: Get rid of alloca. 2023-08-30 12:29 ` Joe Simmons-Talbott @ 2023-09-04 1:12 ` Ying Huang 0 siblings, 0 replies; 9+ messages in thread From: Ying Huang @ 2023-09-04 1:12 UTC (permalink / raw) To: Joe Simmons-Talbott; +Cc: libc-alpha [-- Attachment #1: Type: text/plain, Size: 3464 bytes --] Hi Joe, 在 2023/8/30 20:29, Joe Simmons-Talbott 写道: > 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 Yes, my pleasure. And I also did test on gcc 12.2.0, binutils 2.40, mipsel-linux-gnu. It was good, too. >> >> 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 >>>> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3] mips: dl-machine-reject-phdr: Get rid of alloca. 2023-08-29 19:30 ` Joe Simmons-Talbott 2023-08-30 8:18 ` Ying Huang @ 2023-09-07 12:25 ` Joe Simmons-Talbott 2023-09-21 11:52 ` Joe Simmons-Talbott 1 sibling, 1 reply; 9+ messages in thread From: Joe Simmons-Talbott @ 2023-09-07 12:25 UTC (permalink / raw) To: libc-alpha Ping for review. On Tue, Aug 29, 2023 at 03:30:19PM -0400, Joe Simmons-Talbott via Libc-alpha wrote: > 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 > > > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3] mips: dl-machine-reject-phdr: Get rid of alloca. 2023-09-07 12:25 ` Joe Simmons-Talbott @ 2023-09-21 11:52 ` Joe Simmons-Talbott 2023-10-02 11:52 ` Joe Simmons-Talbott 0 siblings, 1 reply; 9+ messages in thread From: Joe Simmons-Talbott @ 2023-09-21 11:52 UTC (permalink / raw) To: libc-alpha Ping. On Thu, Sep 07, 2023 at 08:25:50AM -0400, Joe Simmons-Talbott wrote: > Ping for review. > > On Tue, Aug 29, 2023 at 03:30:19PM -0400, Joe Simmons-Talbott via Libc-alpha wrote: > > 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 > > > > > > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3] mips: dl-machine-reject-phdr: Get rid of alloca. 2023-09-21 11:52 ` Joe Simmons-Talbott @ 2023-10-02 11:52 ` Joe Simmons-Talbott 0 siblings, 0 replies; 9+ messages in thread From: Joe Simmons-Talbott @ 2023-10-02 11:52 UTC (permalink / raw) To: libc-alpha Ping. On Thu, Sep 21, 2023 at 07:52:35AM -0400, Joe Simmons-Talbott wrote: > Ping. > > On Thu, Sep 07, 2023 at 08:25:50AM -0400, Joe Simmons-Talbott wrote: > > Ping for review. > > > > On Tue, Aug 29, 2023 at 03:30:19PM -0400, Joe Simmons-Talbott via Libc-alpha wrote: > > > 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 > > > > > > > > > > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3] mips: dl-machine-reject-phdr: Get rid of alloca. 2023-06-26 13:16 [PATCH v3] mips: dl-machine-reject-phdr: Get rid of alloca Joe Simmons-Talbott 2023-08-29 19:30 ` Joe Simmons-Talbott @ 2023-10-02 12:13 ` Adhemerval Zanella Netto 1 sibling, 0 replies; 9+ messages in thread From: Adhemerval Zanella Netto @ 2023-10-02 12:13 UTC (permalink / raw) To: Joe Simmons-Talbott, libc-alpha On 26/06/23 10:16, Joe Simmons-Talbott via Libc-alpha 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(-) LGTM, thanks. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> > > 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. */ ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-10-02 12:13 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-06-26 13:16 [PATCH v3] mips: dl-machine-reject-phdr: Get rid of alloca Joe Simmons-Talbott 2023-08-29 19:30 ` Joe Simmons-Talbott 2023-08-30 8:18 ` Ying Huang 2023-08-30 12:29 ` Joe Simmons-Talbott 2023-09-04 1:12 ` Ying Huang 2023-09-07 12:25 ` Joe Simmons-Talbott 2023-09-21 11:52 ` Joe Simmons-Talbott 2023-10-02 11:52 ` Joe Simmons-Talbott 2023-10-02 12:13 ` Adhemerval Zanella Netto
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).