From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754496AbcAVRA6 (ORCPT ); Fri, 22 Jan 2016 12:00:58 -0500 Received: from arcturus.aphlor.org ([188.246.204.175]:45890 "EHLO arcturus.aphlor.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754173AbcAVRA4 (ORCPT ); Fri, 22 Jan 2016 12:00:56 -0500 Date: Fri, 22 Jan 2016 12:00:53 -0500 From: Dave Jones To: Andrey Ryabinin Cc: Linux Kernel Mailing List Subject: Re: UBSAN: run-time undefined behavior sanity checker Message-ID: <20160122170053.GB30299@codemonkey.org.uk> Mail-Followup-To: Dave Jones , Andrey Ryabinin , Linux Kernel Mailing List References: <20160121205717.AF61F661293@gitolite.kernel.org> <20160122051539.GA1326@codemonkey.org.uk> <56A25C4B.2000204@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <56A25C4B.2000204@virtuozzo.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Spam-Score: -2.9 (--) X-Spam-Report: Spam detection software, running on the system "arcturus.aphlor.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: On Fri, Jan 22, 2016 at 07:43:55PM +0300, Andrey Ryabinin wrote: > On 01/22/2016 08:15 AM, Dave Jones wrote: > > On Thu, Jan 21, 2016 at 08:57:17PM +0000, Linux Kernel wrote: > > > Web: https://git.kernel.org/torvalds/c/c6d308534aef6c99904bf5862066360ae067abc4 > > > Commit: c6d308534aef6c99904bf5862066360ae067abc4 > > > Parent: 68920c973254c5b71a684645c5f6f82d6732c5d6 > > > Refname: refs/heads/master > > > Author: Andrey Ryabinin > > > AuthorDate: Wed Jan 20 15:00:55 2016 -0800 > > > Committer: Linus Torvalds > > > CommitDate: Wed Jan 20 17:09:18 2016 -0800 > > > > > > UBSAN: run-time undefined behavior sanity checker > > > > > > UBSAN uses compile-time instrumentation to catch undefined behavior > > > (UB). Compiler inserts code that perform certain kinds of checks before > > > operations that could cause UB. If check fails (i.e. UB detected) > > > __ubsan_handle_* function called to print error message. > > > > > > So the most of the work is done by compiler. This patch just implements > > > ubsan handlers printing errors. > > > > > > GCC has this capability since 4.9.x [1] (see -fsanitize=undefined > > > option and its suboptions). > > > However GCC 5.x has more checkers implemented [2]. > > > Article [3] has a bit more details about UBSAN in the GCC. > > > > If I enable this and CONFIG_UBSAN_ALIGNMENT, the kernel doesn't boot, > > and hangs really early (pretty much as soon as I hit return in grub) > > far too early for serial console or even tty output. > > > > Compiler is debian unstable's 5.3.1 20160114 > > > > I don't know if this is worth chasing down, I chose to just disable it, > > but figured I'd post in case other people stumble across the same issue. > > > > Likely caused by unaligned access in very early code, which ends up in too early printk() call. > You could try to disable instrumentation (UBSAN_SANITIZE := n) in early code. > > Be aware that CONFIG_UBSAN_ALIGNMENT causes a *lot* of spam in dmesg. Since x86 supports unaligned > [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 22, 2016 at 07:43:55PM +0300, Andrey Ryabinin wrote: > On 01/22/2016 08:15 AM, Dave Jones wrote: > > On Thu, Jan 21, 2016 at 08:57:17PM +0000, Linux Kernel wrote: > > > Web: https://git.kernel.org/torvalds/c/c6d308534aef6c99904bf5862066360ae067abc4 > > > Commit: c6d308534aef6c99904bf5862066360ae067abc4 > > > Parent: 68920c973254c5b71a684645c5f6f82d6732c5d6 > > > Refname: refs/heads/master > > > Author: Andrey Ryabinin > > > AuthorDate: Wed Jan 20 15:00:55 2016 -0800 > > > Committer: Linus Torvalds > > > CommitDate: Wed Jan 20 17:09:18 2016 -0800 > > > > > > UBSAN: run-time undefined behavior sanity checker > > > > > > UBSAN uses compile-time instrumentation to catch undefined behavior > > > (UB). Compiler inserts code that perform certain kinds of checks before > > > operations that could cause UB. If check fails (i.e. UB detected) > > > __ubsan_handle_* function called to print error message. > > > > > > So the most of the work is done by compiler. This patch just implements > > > ubsan handlers printing errors. > > > > > > GCC has this capability since 4.9.x [1] (see -fsanitize=undefined > > > option and its suboptions). > > > However GCC 5.x has more checkers implemented [2]. > > > Article [3] has a bit more details about UBSAN in the GCC. > > > > If I enable this and CONFIG_UBSAN_ALIGNMENT, the kernel doesn't boot, > > and hangs really early (pretty much as soon as I hit return in grub) > > far too early for serial console or even tty output. > > > > Compiler is debian unstable's 5.3.1 20160114 > > > > I don't know if this is worth chasing down, I chose to just disable it, > > but figured I'd post in case other people stumble across the same issue. > > > > Likely caused by unaligned access in very early code, which ends up in too early printk() call. > You could try to disable instrumentation (UBSAN_SANITIZE := n) in early code. > > Be aware that CONFIG_UBSAN_ALIGNMENT causes a *lot* of spam in dmesg. Since x86 supports unaligned > accesses, the significant amount of that spam just a false-positive reports. So disabling that option fixed booting on one machine, but every other I've tried it on hangs the same way, really early. Any thoughts on how to chase this down ? Dave