Re: panic: invalid bcd xxx

From: Eric van Gyzen <vangyzen_at_FreeBSD.org>
Date: Tue, 28 Feb 2017 16:31:36 -0600
On 02/28/2017 15:47, Michael Gmelin wrote:
> Booting r313561[0] I get the following panic:
>
> mountroot: waiting for device /dev/ufs/FreeBSD_install
> panic: invalid bcd 177 (also 254, 255 etc.)
> cpuid = 1
> KDB: stack backtrace:
> db_trace_self_wrapper...
> vpanic()...
> kassert_panic()...
> atrtc_gettime()...
> inittodr()...
> vfs_mountroot()...
> start_init()...
> fork_exit()...
> fork_trampoline()...
> (copied from a screenshot, hence the ellipsis)
>
> This is on an Acer C720 Chromebook, confirmed on two devices (one with
> cyapa touchpad, one with elan touchpad). Same problem happened with a
> CURRENT checked out about 10 hours ago. Previous versions of 12-CURRENT
> worked ok (last version I tested personally was back in
> November/December though).

Your system's real-time clock is returning garbage.  r312702 added some 
input validation a few weeks ago.  Previously, the kernel was reading 
beyond the end of an array and either complaining about the clock or 
setting it to the wrong time based on whatever was in the memory beyond 
the array.

The added validation shouldn't be an assertion because it operates on 
data beyond the kernel's control.  Try this:

--- sys/libkern.h	(revision 314424)
+++ sys/libkern.h	(working copy)
_at__at_ -57,8 +57,10 _at__at_
  bcd2bin(int bcd)
  {

-	KASSERT(bcd >= 0 && bcd < LIBKERN_LEN_BCD2BIN,
-	    ("invalid bcd %d", bcd));
+	if (bcd < 0 || bcd >= LIBKERN_LEN_BCD2BIN) {
+		printf("invalid bcd %d\n", bcd);
+		return (0);
+	}
  	return (bcd2bin_data[bcd]);
  }

Eric
Received on Tue Feb 28 2017 - 21:31:44 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:10 UTC