From owner-freebsd-bugs@FreeBSD.ORG Tue Oct 25 01:40:18 2005 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1687616A41F for ; Tue, 25 Oct 2005 01:40:18 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2D6BD43D49 for ; Tue, 25 Oct 2005 01:40:17 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j9P1eG8w090357 for ; Tue, 25 Oct 2005 01:40:16 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j9P1eGuA090356; Tue, 25 Oct 2005 01:40:16 GMT (envelope-from gnats) Resent-Date: Tue, 25 Oct 2005 01:40:16 GMT Resent-Message-Id: <200510250140.j9P1eGuA090356@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, "Frank Mayhar" Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7105016A41F for ; Tue, 25 Oct 2005 01:30:18 +0000 (GMT) (envelope-from frank@exit.com) Received: from tinker.exit.com (tinker.exit.com [206.223.0.1]) by mx1.FreeBSD.org (Postfix) with ESMTP id 09B6C43D48 for ; Tue, 25 Oct 2005 01:30:17 +0000 (GMT) (envelope-from frank@exit.com) Received: from realtime.exit.com (realtime [206.223.0.5]) by tinker.exit.com (8.13.4/8.13.4) with ESMTP id j9P1UIiU053876 for ; Mon, 24 Oct 2005 18:30:18 -0700 (PDT) (envelope-from frank@exit.com) Message-Id: <1130203817.0@realtime.exit.com> Date: Mon, 24 Oct 2005 18:30:17 -0700 From: "Frank Mayhar" To: "FreeBSD gnats submit" X-Send-Pr-Version: gtk-send-pr 0.4.6 Cc: Subject: bin/87964: [patch] Fix kgdb msgbuf bogosity and infinite loop. X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Oct 2005 01:40:18 -0000 >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: