From owner-freebsd-current@freebsd.org Tue Feb 28 23:26:24 2017 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 84CBBCF20E4 for ; Tue, 28 Feb 2017 23:26:24 +0000 (UTC) (envelope-from freebsd@grem.de) Received: from mail.grem.de (outcast.grem.de [213.239.217.27]) by mx1.freebsd.org (Postfix) with SMTP id ED8E1B01 for ; Tue, 28 Feb 2017 23:26:23 +0000 (UTC) (envelope-from freebsd@grem.de) Received: (qmail 15653 invoked by uid 89); 28 Feb 2017 23:26:22 -0000 Received: from unknown (HELO bsd64.grem.de) (mg@grem.de@194.97.158.70) by mail.grem.de with ESMTPA; 28 Feb 2017 23:26:22 -0000 Date: Wed, 1 Mar 2017 00:26:20 +0100 From: Michael Gmelin To: Eric van Gyzen Cc: cem@freebsd.org, "freebsd-current@freebsd.org" Subject: Re: panic: invalid bcd xxx Message-ID: <20170301002620.6a5e35ce@bsd64.grem.de> In-Reply-To: References: <20170228224739.167f2273@bsd64.grem.de> <226a00fa-5d04-0aa7-e0cc-6078edde6639@FreeBSD.org> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.29; amd64-portbld-freebsd10.2) X-Face: $wrgCtfdVw_H9WAY?S&9+/F"!41z'L$uo*WzT8miX?kZ~W~Lr5W7v?j0Sde\mwB&/ypo^}> +a'4xMc^^KroE~+v^&^#[B">soBo1y6(TW6#UZiC]o>C6`ej+i Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJFBMVEWJBwe5BQDl LASZU0/LTEWEfHbyj0Txi32+sKrp1Mv944X8/fm1rS+cAAAACXBIWXMAAAsTAAAL EwEAmpwYAAAAB3RJTUUH3wESCxwC7OBhbgAAACFpVFh0Q29tbWVudAAAAAAAQ3Jl YXRlZCB3aXRoIFRoZSBHSU1QbbCXAAAAAghJREFUOMu11DFvEzEUAGCfEhBVFzuq AKkLd0O6VrIQsLXVSZXoWE5N1K3DobBBA9fQpRWc8OkWouaIjedWKiyREOKs+3PY fvalCNjgLVHeF7/3bMtBzV8C/VsQ8tecEgCcDgrzjekwKZ7TwsJZd/ywEKwwP+ZM 8P3drTsAwWn2mpWuDDuYiK1bFs6De0KUUFw0tWxm+D4AIhuuvZqtyWYeO7jQ4Aea 7jUqI+ixhQoHex4WshEvSXdood7stlv4oSuFOC4tqGcr0NjEqXgV4mMJO38nld4+ xKNxRDon7khyKVqY7YR4d+Cg0OMrkWXZOM7YDkEfKiilCn1qYv4mighZiynuHHOA Wq9QJq+BIES7lMFUtcikMnkDGHUoncA+uHgrP0ctIEqfwLHzeSo+eUA66AqzwN6n 2ZHJhw6Qh/PoyC/QENyEyC/AyNjq74Bs+3UH0xYwzDUC4B97HgLocg1QLYgDDO1v f3UX9Y307Ew4AHh67YAFFsxEpkXwpXY3eIgMhAAE3R19L919nNnuD2wlPcDE3UeT L2ytEICQib9BXgS2fU8PrD82ToYO1OEmMSnYTjSqSv9wdC0tPYC+rQRQD9ESnldF CyqfmiYW+tlALt8gH2xrMdC/youbjzPXEun+/ReXsMCDyve3dZc09fn2Oas8oXGc Jj6/fOeK5UmSMPmf/jL+GD8BEj0k/Fn6IO4AAAAASUVORK5CYII= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Feb 2017 23:26:24 -0000 On Tue, 28 Feb 2017 17:16:02 -0600 Eric van Gyzen wrote: > On 02/28/2017 16:57, Conrad Meyer wrote: > > On Tue, Feb 28, 2017 at 2:31 PM, Eric van Gyzen > > 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