panic: invalid bcd xxx
Michael Gmelin
freebsd at grem.de
Tue Feb 28 23:26:24 UTC 2017
On Tue, 28 Feb 2017 17:16:02 -0600
Eric van Gyzen <vangyzen at FreeBSD.org> wrote:
> On 02/28/2017 16:57, Conrad Meyer wrote:
> > On Tue, Feb 28, 2017 at 2:31 PM, Eric van Gyzen
> > <vangyzen at freebsd.org> wrote:
> >> 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]);
> >> }
> >
> > I don't think removing this assertion and truncating to zero is the
> > right thing to do. Adding an error return to this routine is a
> > little much, though. I think probably the caller should perform
> > input validation between the broken device and this routine.
>
> Either of those would be a much better solution. This was just a
> quick hack to get the memstick to boot.
>
Thanks for your response.
I'm not in a hurry, so I can wait for a proper solution. Let me know if
I should test anything or can help in some other way.
-m
--
Michael Gmelin
More information about the freebsd-current
mailing list