From owner-freebsd-current@freebsd.org Wed Mar 1 23:35:16 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 7CD69CF4EAD for ; Wed, 1 Mar 2017 23:35:16 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-wm0-x230.google.com (mail-wm0-x230.google.com [IPv6:2a00:1450:400c:c09::230]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 120A8218; Wed, 1 Mar 2017 23:35:16 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: by mail-wm0-x230.google.com with SMTP id n11so11590875wma.0; Wed, 01 Mar 2017 15:35:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=S4JZd0kUo4lNE+KReRT0qru1T1EkLij7k28yUW+7RyI=; b=lKk+eyeMD8RavGXYMyJ6UyvRFIRMuz+TRAZ3AC9k0rIej44fVaa8oZR38aODeQZ3SW RGD1GyMrbBuSfBMxpUS6jlQtuUEPtNYadlSxhmKmsqVvyrTkBpmc0nAsWCCTnqUEndiZ eQ2v2XfLj/GfS9Txc1jp3KIAlxBFVtbK7dY3brnQXGuehcDoNWxlxMfVGmZfwNClj2AR ek/7DRObqJEMHZRwE1tw/sE8DAhNMUMqTYV7Q43MoieZ/5FLfGSmgEsZEdCH2h46Xl+9 HXAddD6pMb7FLEl6utxOkVobq9Fc+rGiyqzcpmctUggN4L91cFAq39qFRDUGnx6c6Xg+ UupQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=S4JZd0kUo4lNE+KReRT0qru1T1EkLij7k28yUW+7RyI=; b=rANpzsjsaC8i2fo4m3CDyYqsPRqjJo6diYGBon0ZjjMUJR6hux50Z0p76U7SmshtOz Ra0fZH+EOEQj0nyoMZEf+DNiBgvp5pYpQwNFHxNm8TI475ZCAxOjpMU+QHSYcGO5VoBS oiXBjiauEo0bQBUIJ/9duXsj0LEbQGo+gPI47keEx2XjZ5SlMRh0luGPv4v7+ZjTLnb9 /nSlMlXYarLGIRXsib5/mP1upalGrhEjxFXVEi1GFIcKQ84RmXVkUnSbkAaXdYKjuUSp 5v/Y9wHZDL/+c3lJ+6MukPUFHP/eCZ6+8xgUhIev5df3qvr0ZSDDlIboJnC4YOs4/dIx Hi9w== X-Gm-Message-State: AMke39kHRLZnRyhLOsxJ6Zg4zr/Q3WacdikNKC6IHLEEy2NUqm7cKW5F7RPXMkx1hCm4bOLGd5+q6TgXnnrOoQ== X-Received: by 10.28.21.81 with SMTP id 78mr5247256wmv.138.1488411314279; Wed, 01 Mar 2017 15:35:14 -0800 (PST) MIME-Version: 1.0 Received: by 10.28.128.133 with HTTP; Wed, 1 Mar 2017 15:35:13 -0800 (PST) In-Reply-To: <20170301002620.6a5e35ce@bsd64.grem.de> References: <20170228224739.167f2273@bsd64.grem.de> <226a00fa-5d04-0aa7-e0cc-6078edde6639@FreeBSD.org> <20170301002620.6a5e35ce@bsd64.grem.de> From: Adrian Chadd Date: Wed, 1 Mar 2017 15:35:13 -0800 Message-ID: Subject: Re: panic: invalid bcd xxx To: Michael Gmelin Cc: Eric van Gyzen , "Conrad E. Meyer" , "freebsd-current@freebsd.org" Content-Type: text/plain; charset=UTF-8 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: Wed, 01 Mar 2017 23:35:16 -0000 This is an emulated BIOS though, right? I don't know if we're going to get the RTC 'bugfixed'... -adrian On 28 February 2017 at 15:26, Michael Gmelin wrote: > 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 > _______________________________________________ > freebsd-current@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"