From owner-freebsd-audit  Sun Dec 31  8:26:33 2000
From owner-freebsd-audit@FreeBSD.ORG  Sun Dec 31 08:26:31 2000
Return-Path: <owner-freebsd-audit@FreeBSD.ORG>
Delivered-To: freebsd-audit@freebsd.org
Received: from mailout02.sul.t-online.com (mailout02.sul.t-online.com [194.25.134.17])
	by hub.freebsd.org (Postfix) with ESMTP id 9B57237B400
	for <audit@freebsd.org>; Sun, 31 Dec 2000 08:26:30 -0800 (PST)
Received: from fwd06.sul.t-online.com 
	by mailout02.sul.t-online.com with smtp 
	id 14ClJV-0006Ww-01; Sun, 31 Dec 2000 17:26:29 +0100
Received: from neutron.cichlids.com (520050424122-0001@[62.157.56.132]) by fmrl06.sul.t-online.com
	with esmtp id 14ClJL-1zgQsaC; Sun, 31 Dec 2000 17:26:19 +0100
Received: from cichlids.cichlids.com (cichlids.cichlids.com [192.168.0.10])
	by neutron.cichlids.com (Postfix) with ESMTP id AD639AB0C
	for <audit@freebsd.org>; Sun, 31 Dec 2000 17:26:43 +0100 (CET)
Received: by cichlids.cichlids.com (Postfix, from userid 1001)
	id 9F16614AF8; Sun, 31 Dec 2000 17:26:07 +0100 (CET)
Date: Sun, 31 Dec 2000 17:26:07 +0100
To: audit@freebsd.org
Subject: getnanouptime() patch
Message-ID: <20001231172607.A175@cichlids.cichlids.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.2.5i
X-PGP-Fingerprint: 44 28 CA 4C 46 5B D3 A8  A8 E3 BA F3 4E 60 7D 7F
X-PGP-at: finger alex@big.endian.de
X-Verwirrung: Dieser Header dient der allgemeinen Verwirrung.
From: alex@big.endian.de (Alexander Langer)
X-Sender: 520050424122-0001@t-dialin.net
Sender: owner-freebsd-audit@FreeBSD.ORG
Precedence: bulk
X-Loop: FreeBSD.ORG

Hello!

I have this old mail from BDE sitting here about the print_uptime()
bugs.  One of these bugs is:

- the implementation is buggy.  getnanouptime() accesses uninitialized
  pointers when it is called before timecounters have been
initialized.
  This causes recursive panics which lock up at least my systems (boot
  with -d and decide you didn't want to boot this kernel after all,
  and type "panic" at the debugger prompt -- this locks up the system).

The following patch to getnanouptime() should fix this.

I don't know what the KTR define is for, I stole this from another
function in the kern_tc.c file, which also handles uninitialized
pointer correctly.

Comments?


cvs diff: Diffing .
Index: kern_tc.c
===================================================================
RCS file: /usr/home/ncvs/src/sys/kern/kern_tc.c,v
retrieving revision 1.109
diff -u -r1.109 kern_tc.c
--- kern_tc.c	2000/09/07 01:32:51	1.109
+++ kern_tc.c	2000/12/31 16:23:27
@@ -188,6 +188,13 @@
 
 	ngetnanouptime++;
 	tc = timecounter;
+#ifdef KTR
+	if (tc == NULL) {		/* called before initialization */
+		tsp->tv_sec = 0;
+		tsp->tv_nsec = 0;
+		return;
+	}
+#endif
 	tsp->tv_sec = tc->tc_offset_sec;
 	tsp->tv_nsec = tc->tc_offset_nano >> 32;
 }

-- 
cat: /home/alex/.sig: No such file or directory


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message