Bug 710668 - using gdb to debug kernel causes crash
Summary: using gdb to debug kernel causes crash
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: kernel
Version: 6.1
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Prarit Bhargava
QA Contact: WANG Chao
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-06-04 00:03 UTC by Michael Hebenstreit
Modified: 2018-11-26 17:46 UTC (History)
4 users (show)

Fixed In Version: kernel-2.6.32-171.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-12-06 13:32:50 UTC
Target Upstream Version:


Attachments (Terms of Use)
RHEL6 patch for this issue (1.47 KB, patch)
2011-07-13 19:00 UTC, Prarit Bhargava
no flags Details | Diff


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2011:1530 normal SHIPPED_LIVE Moderate: Red Hat Enterprise Linux 6 kernel security, bug fix and enhancement update 2011-12-06 01:45:35 UTC

Description Michael Hebenstreit 2011-06-04 00:03:23 UTC
Description of problem:
kernel misses a bugfix to cover GDB 6.8 -> 7.2 changes
bug alread described in http://sourceware.org/bugzilla/show_bug.cgi?id=12146
fix in http://kerneltrap.org/mailarchive/linux-kernel/2010/7/22/4596723

Comment 2 Prarit Bhargava 2011-06-10 11:42:44 UTC
Hi Michael,

I'm not set up to run gdb here -- you seem knowledgeable enough to backport the patch and test.  Would you mind doing so and posting the result here?

I can then see about backporting it to RHEL6.

Thanks :)

P.

Comment 3 Michael Hebenstreit 2011-06-10 15:29:47 UTC
I used thia patch, seems to work now:

[mhebenst@eln1 development]$ cat linux-2.6.32-131.0.15.el6.x86_64.crt.1.debug/kgdb_1.patch
diff --git a/kernel/debug/gdbstub.c b/kernel/debug/gdbstub.c
index 4b17b32..e8fd686 100644
--- a/kernel/debug/gdbstub.c
+++ b/kernel/debug/gdbstub.c
@@ -621,10 +621,8 @@ static void gdb_cmd_query(struct kgdb_state *ks)
        switch (remcom_in_buffer[1]) {
        case 's':
        case 'f':
-               if (memcmp(remcom_in_buffer + 2, "ThreadInfo", 10)) {
-                       error_packet(remcom_out_buffer, -EINVAL);
+               if (memcmp(remcom_in_buffer + 2, "ThreadInfo", 10))
                        break;
-               }

                i = 0;
                remcom_out_buffer[0] = 'm';
@@ -665,10 +663,9 @@ static void gdb_cmd_query(struct kgdb_state *ks)
                pack_threadid(remcom_out_buffer + 2, thref);
                break;
        case 'T':
-               if (memcmp(remcom_in_buffer + 1, "ThreadExtraInfo,", 16)) {
-                       error_packet(remcom_out_buffer, -EINVAL);
+               if (memcmp(remcom_in_buffer + 1, "ThreadExtraInfo,", 16))
                        break;
-               }
+
                ks->threadid = 0;
                ptr = remcom_in_buffer + 17;
                kgdb_hex2long(&ptr, &ks->threadid);

Comment 4 Prarit Bhargava 2011-07-13 14:26:29 UTC
Michael, thanks for testing.  I will compile test and push for internal review.

Again, thanks :)

P.

Comment 5 Prarit Bhargava 2011-07-13 17:18:34 UTC
Michael,

... are you sure that's the patch?  I don't see a kernel/debug/ dir in RHEL6...

P.

Comment 6 Michael Hebenstreit 2011-07-13 17:37:13 UTC
ups - you are right - I posted the original patch - here is my change to the RH kernel - second try:

--- linux-2.6.32-131.0.15.el6.x86_64.crt.1/kernel/kgdb.c     2009-12-02 19:51:21.000000000 -0800
+++ linux-2.6.32-131.0.15.el6.x86_64.crt.1.debug/kernel/kgdb.c 2011-06-03 16:12:29.596472000 -0700
@@ -1001,10 +1001,8 @@
        switch (remcom_in_buffer[1]) {
        case 's':
        case 'f':
-               if (memcmp(remcom_in_buffer + 2, "ThreadInfo", 10)) {
-                       error_packet(remcom_out_buffer, -EINVAL);
+               if (memcmp(remcom_in_buffer + 2, "ThreadInfo", 10))
                        break;
-               }

                i = 0;
                remcom_out_buffer[0] = 'm';
@@ -1045,10 +1043,9 @@
                pack_threadid(remcom_out_buffer + 2, thref);
                break;
        case 'T':
-               if (memcmp(remcom_in_buffer + 1, "ThreadExtraInfo,", 16)) {
-                       error_packet(remcom_out_buffer, -EINVAL);
+               if (memcmp(remcom_in_buffer + 1, "ThreadExtraInfo,", 16))
                        break;
-               }
+
                ks->threadid = 0;
                ptr = remcom_in_buffer + 17;
                kgdb_hex2long(&ptr, &ks->threadid);

Comment 7 Prarit Bhargava 2011-07-13 18:08:52 UTC
(In reply to comment #6)
> ups - you are right - I posted the original patch - here is my change to the RH
> kernel - second try:
> 

Heh ... np :)   I thought that was the what you backported to but I just wanted to make sure I post what you tested :)

P.

Comment 8 Prarit Bhargava 2011-07-13 19:00:17 UTC
Created attachment 512725 [details]
RHEL6 patch for this issue

Comment 9 RHEL Program Management 2011-07-13 19:21:12 UTC
This request was evaluated by Red Hat Product Management for inclusion
in a Red Hat Enterprise Linux maintenance release. Product Management has 
requested further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed 
products. This request is not yet committed for inclusion in an Update release.

Comment 11 Kyle McMartin 2011-07-25 13:07:15 UTC
Patch(es) available on kernel-2.6.32-171.el6

Comment 15 WANG Chao 2011-11-09 04:31:36 UTC
Just to mark how I setup kgdb environment:
connect console serial port between two machines as target:/dev/ttyS0 <--> development:/dev/ttyUSB0
On target machine, add kernel param 'kgdboc=ttyS0,115200 kgdbwait'.
On development machine, use gdb to load kernel-debuginfo/vmlinux.
   
Reproduce on 2.6.32-131.15.el6:
[snip]
Reading symbols from /root/vmlinux-131...done.
(gdb) target remote /dev/ttyUSB0
Remote debugging using /dev/ttyUSB0
0xffffffff810d42bb in kgdb_initial_breakpoint (new_kgdb_io_ops=0xffffffff81afe6e0) at kernel/kgdb.c:1630
1630		printk(KERN_CRIT "kgdb: Waiting for connection from remote gdb...\n");
trace API error 0x2.
(gdb) quit

Verified on 2.6.32-216.el6:
[snip]
Reading symbols from /root/vmlinux-214...done.
(gdb) target remote /dev/ttyUSB0
Remote debugging using /dev/ttyUSB0
kgdb_breakpoint (new_kgdb_io_ops=0xffffffff81aff4a0) at kernel/kgdb.c:1718
1718		wmb(); /* Sync point after breakpoint */
(gdb) quit
A debugging session is active.

	Inferior 1 [Remote target] will be killed.

Quit anyway? (y or n) y

On 2.6.32-216.el6, kgdb works correctly as expected(no error message)

Set bug status to verified.

Comment 16 errata-xmlrpc 2011-12-06 13:32:50 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHSA-2011-1530.html


Note You need to log in before you can comment on or make changes to this bug.