panic: invalid bcd xxx

Eric van Gyzen vangyzen at FreeBSD.org
Tue Feb 28 22:31:44 UTC 2017


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)
@@ -57,8 +57,10 @@
  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


More information about the freebsd-current mailing list