Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Paul Pluzhnikov <ppluzhnikov@google.com>
To: gdb-patches@sourceware.org
Cc: ppluzhnikov@google.com
Subject: [patch] Fix crash in svr4_clear_so
Date: Tue, 21 May 2013 22:23:00 -0000	[thread overview]
Message-ID: <ye6qa9no55vu.fsf@elbrus2.mtv.corp.google.com> (raw)

Greetings,

Using current trunk, I've got a GDB core dump when I tried to analyze
mis-matched binary and core:

gdb a.out core
GNU gdb (GDB) 7.6.50.20130521-cvs
...
warning: core file may not match specified executable file.
[New LWP 29265]
...
[New LWP 27085]
[New LWP 27052]
warning: Error reading shared library list entry at 0x3b48104f8b480000
Segmentation fault

The actual crash is happening here:

Program received signal SIGSEGV, Segmentation fault.
0x0000000000481376 in svr4_clear_so (so=0xc833490) at ../../src/gdb/solib-svr4.c:974
974       so->lm_info->l_addr_p = 0;

#0  0x0000000000481376 in svr4_clear_so (so=0xc833490) at ../../src/gdb/solib-svr4.c:974
#1  0x0000000000708bc4 in clear_so (so=0xc833490) at ../../src/gdb/solib.c:537
#2  0x0000000000708bef in free_so (so=0xc833490) at ../../src/gdb/solib.c:556
#3  0x00000000006ee328 in do_free_so (arg=0xc833490) at ../../src/gdb/utils.c:492
#4  0x0000000000573474 in do_my_cleanups (pmy_chain=0xc5c1f0 <cleanup_chain>, old_chain=0x35232410) at ../../src/gdb/cleanups.c:155
#5  0x00000000005734e1 in do_cleanups (old_chain=0x35232410) at ../../src/gdb/cleanups.c:177
#6  0x00000000004817e0 in svr4_read_so_list (lm=4271682180386127872, link_ptr_ptr=0x7fff7fc37c58, ignore_first=1) at ../../src/gdb/solib-svr4.c:1195
#7  0x0000000000481b01 in svr4_current_sos () at ../../src/gdb/solib-svr4.c:1311
#8  0x0000000000708eea in update_solib_list (from_tty=0, target=0xc724c0 <core_ops>) at ../../src/gdb/solib.c:674
...

Attached patch fixes the GDB crash.

Ok for trunk?

Thanks,
--

2013-05-21  Paul Pluzhnikov  <ppluzhnikov@google.com>

	* solib-svr4.c (svr4_free_so): Protect against NULL dereference.


Index: solib-svr4.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-svr4.c,v
retrieving revision 1.177
diff -p -u -r1.177 solib-svr4.c
--- solib-svr4.c	6 May 2013 22:18:38 -0000	1.177
+++ solib-svr4.c	21 May 2013 22:19:09 -0000
@@ -971,7 +971,8 @@ svr4_free_so (struct so_list *so)
 static void
 svr4_clear_so (struct so_list *so)
 {
-  so->lm_info->l_addr_p = 0;
+  if (so->lm_info != NULL)
+    so->lm_info->l_addr_p = 0;
 }
 
 /* Free so_list built so far (called via cleanup).  */


             reply	other threads:[~2013-05-21 22:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-21 22:23 Paul Pluzhnikov [this message]
2013-05-21 23:14 ` Doug Evans
2013-05-22 10:32 ` Gary Benson

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=ye6qa9no55vu.fsf@elbrus2.mtv.corp.google.com \
    --to=ppluzhnikov@google.com \
    --cc=gdb-patches@sourceware.org \
    /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