From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: aristovski@qnx.com
Cc: gdb-patches@sources.redhat.com
Subject: Re: [patch] nto target: fix null pointer dereference
Date: Wed, 13 Aug 2008 13:30:00 -0000 [thread overview]
Message-ID: <200808131329.m7DDTCWK022235@d12av02.megacenter.de.ibm.com> (raw)
Aleksandar Ristovski wrote:
> Ulrich Weigand wrote:
> > Can you explain what the situation is that leads to a NULL
> > pointer here?
>
> Your question made me go through the issue again.
>
> To create inferior, we use spawnp. spawnp will do something like mmap
> the binary and that's pretty much it (DT_DEBUG in .dynamic will contain
> NULL pointer).
>
> In procfs_create_inferior we call solib_create_inferior_hook, which will
> end up trying to determine loader base by reading inferior's memory at
> DT_DEBUG pointer. In our case, before the executable actually started
> executing, it will successfully read 0s, because dynamic loader has not
> been invoked yet, and the pointer to r_debug structure is not initialized.
I see. However, so->lm_info->lm should still be always allocated by the
common solib-svr4.c routines (see svr4_current_sos):
new->lm_info->l_addr = (CORE_ADDR)-1;
new->lm_info->lm_addr = lm;
new->lm_info->lm = xzalloc (lmo->link_map_size);
The only case where it is not allocated is in svr4_default_sos (which I
guess can happen in your case if the loader base is not found).
However, there the comment says:
/* Nothing will ever check the cached copy of the link
map if we set l_addr. */
new->lm_info->l_addr = debug_loader_offset;
new->lm_info->lm_addr = 0;
new->lm_info->lm = NULL;
Note the assumption that <lm> is only every used if <l_addr> is
not equal to -1. This is also what the solib-svr4.c implementation
of LM_ADDR_CHECK does.
It seems the main problem is that NTO at some time copied some of
the logic from solib-svr4.c, but has not adapted to the changes that
were added to that file later on. Not even the definition of struct
lm_info matches any more!
Maybe a more correct fix would be to mimic the new solib-svr4.c logic
and use the l_addr field to cache the load address?
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
next reply other threads:[~2008-08-13 13:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-13 13:30 Ulrich Weigand [this message]
2008-08-13 15:50 ` Aleksandar Ristovski
2008-08-14 20:46 ` Aleksandar Ristovski
-- strict thread matches above, loose matches on Subject: below --
2008-08-14 20:51 Ulrich Weigand
2008-08-12 18:33 Ulrich Weigand
2008-08-12 21:26 ` Aleksandar Ristovski
2008-08-12 21:32 ` Daniel Jacobowitz
2008-08-13 15:47 ` Aleksandar Ristovski
2008-08-12 16:38 Aleksandar Ristovski
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=200808131329.m7DDTCWK022235@d12av02.megacenter.de.ibm.com \
--to=uweigand@de.ibm.com \
--cc=aristovski@qnx.com \
--cc=gdb-patches@sources.redhat.com \
/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