Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Oct 2005 18:30:17 -0700
From:      "Frank Mayhar" <frank@exit.com>
To:        "FreeBSD gnats submit" <FreeBSD-gnats-submit@FreeBSD.org>
Subject:   bin/87964: [patch] Fix kgdb msgbuf bogosity and infinite loop.
Message-ID:  <1130203817.0@realtime.exit.com>
Resent-Message-ID: <200510250140.j9P1eGuA090356@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         87964
>Category:       bin
>Synopsis:       [patch] Fix kgdb msgbuf bogosity and infinite loop.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Oct 25 01:40:16 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Frank Mayhar
>Release:        FreeBSD 6.0-RC1 i386
>Organization:
Exit Consulting 
>Environment:


System: FreeBSD 6.0-RC1 #1: Sun Oct 23 09:38:36 PDT 2005
    frank@jill.exit.com:/usr/obj/usr/src/sys/REALTIME



>Description:


Kgdb has code in it to print the "unread portion of the kernel message buffer" when it starts up with a kernel corefile.  Unfortunately this code is broken, at least in 6.0 and later.  One corefile made it print garbage and another put it into an infinite loop.

The attached patch fixes this behavior in both cases.


>How-To-Repeat:





>Fix:


--- kgdb.patch begins here ---
Index: gnu/usr.bin/gdb/kgdb/main.c
===================================================================
RCS file: /cvs/repos/src/gnu/usr.bin/gdb/kgdb/main.c,v
retrieving revision 1.7.2.2
diff -u -r1.7.2.2 main.c
--- gnu/usr.bin/gdb/kgdb/main.c	15 Sep 2005 05:32:10 -0000	1.7.2.2
+++ gnu/usr.bin/gdb/kgdb/main.c	25 Oct 2005 01:13:05 -0000
@@ -197,6 +197,8 @@
 	return (n);
 }
 
+#define MSGBUF_SEQ_TO_POS(size, seq)     ((seq) % (size))
+
 static void
 kgdb_init_target(void)
 {
@@ -241,6 +243,8 @@
 	size = (int)kgdb_parse("msgbufp->msg_size");
 	rseq = (int)kgdb_parse("msgbufp->msg_rseq");
 	wseq = (int)kgdb_parse("msgbufp->msg_wseq");
+	rseq = MSGBUF_SEQ_TO_POS(size, rseq);
+	wseq = MSGBUF_SEQ_TO_POS(size, wseq);
 	if (bufp == 0 || size == 0 || rseq == wseq)
 		return;
 
--- kgdb.patch ends here ---



>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1130203817.0>