public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Xi Ruoyao <xry111@xry111.site>
To: liuzhensong <liuzhensong@loongson.cn>, binutils@sourceware.org
Cc: Chenghua Xu <xuchenghua@loongson.cn>,
	Lulu Cheng <chenglulu@loongson.cn>,  Wang Xuerui <i@xen0n.name>
Subject: Re: [PATCH 1/2] LoongArch: Avoid heap-buffer-overflow in loongarch_elf_relocate_section
Date: Thu, 15 Sep 2022 14:13:45 +0800	[thread overview]
Message-ID: <ebf98cd55669626fbec75b6ceceddb8cd42272a5.camel@xry111.site> (raw)
In-Reply-To: <6fc2821d-5db6-6645-1d5f-8b89eb071fde@loongson.cn>

On Thu, 2022-09-15 at 11:54 +0800, liuzhensong wrote:

> > > > diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
> > > > index a9bb66a1e04..1e8ecb2b8e2 100644
> > > > --- a/bfd/elfnn-loongarch.c
> > > > +++ b/bfd/elfnn-loongarch.c
> > > > @@ -3129,6 +3129,7 @@ loongarch_elf_relocate_section (bfd
> > > > *output_bfd, struct bfd_link_info *info,
> > > >               BFD_ASSERT (rel->r_addend == 0);
> > > >    
> > > >               bfd_vma got_off = 0;
> > > > +             bool fill_got_entry = true;
> > > >               if (h != NULL)
> > > >                 {
> > > >                   /* GOT ref or ifunc.  */
> > > > @@ -3141,6 +3142,10 @@ loongarch_elf_relocate_section (bfd
> > > > *output_bfd, struct bfd_link_info *info,
> > > >                   if (h->got.offset == MINUS_ONE && h->type ==
> > > > STT_GNU_IFUNC)
> > > >                     {
> > > >                       bfd_vma idx;
> > > > +
> > > > +                     /* An IFUNC is always resolved at
> > > > runtime.  */
> Not correct, anything can be filled if h->got.offset != MINUS_ONE.
> There is no space for ifunc to fill got.

Alright, I'm not familiar with BFD and I don't want to spend too much
time (and brain cell deaths) learning it.  So I'll test your change and
if it works let's just do it in your way...

In the meantime please take a look of the 2nd patch, they are different
(and unrelated) issues.


-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

  reply	other threads:[~2022-09-15  6:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-13 15:44 [PATCH 0/2] LoongArch: Fix two bugs breaking IFUNC in static PIE Xi Ruoyao
2022-09-13 15:44 ` [PATCH 1/2] LoongArch: Avoid heap-buffer-overflow in loongarch_elf_relocate_section Xi Ruoyao
2022-09-14  8:57   ` liuzhensong
2022-09-14 10:15     ` Xi Ruoyao
2022-09-14 11:15       ` Xi Ruoyao
2022-09-15  1:47         ` liuzhensong
2022-09-15  2:56           ` Xi Ruoyao
2022-09-15  3:54             ` liuzhensong
2022-09-15  6:13               ` Xi Ruoyao [this message]
2022-09-13 15:44 ` [PATCH 2/2] LoongArch: Fix R_LARCH_IRELATIVE insertion after elf_link_sort_relocs Xi Ruoyao
2022-09-15 13:03   ` liuzhensong
2022-09-16 20:11     ` Xi Ruoyao
2022-09-18  9:58       ` Xi Ruoyao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ebf98cd55669626fbec75b6ceceddb8cd42272a5.camel@xry111.site \
    --to=xry111@xry111.site \
    --cc=binutils@sourceware.org \
    --cc=chenglulu@loongson.cn \
    --cc=i@xen0n.name \
    --cc=liuzhensong@loongson.cn \
    --cc=xuchenghua@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).