From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753424AbcBAQHq (ORCPT ); Mon, 1 Feb 2016 11:07:46 -0500 Received: from mx2.parallels.com ([199.115.105.18]:37570 "EHLO mx2.parallels.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751911AbcBAQHo (ORCPT ); Mon, 1 Feb 2016 11:07:44 -0500 Subject: Re: UBSAN: run-time undefined behavior sanity checker To: Dave Jones , LKML References: <20160121205717.AF61F661293@gitolite.kernel.org> <20160122051539.GA1326@codemonkey.org.uk> <56A25C4B.2000204@virtuozzo.com> <20160122170053.GB30299@codemonkey.org.uk> <56A62B44.2080904@virtuozzo.com> <20160126165322.GA24364@codemonkey.org.uk> From: Andrey Ryabinin Message-ID: <56AF830E.1050707@virtuozzo.com> Date: Mon, 1 Feb 2016 19:08:46 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <20160126165322.GA24364@codemonkey.org.uk> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: US-EXCH.sw.swsoft.com (10.255.249.47) To US-EXCH.sw.swsoft.com (10.255.249.47) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/26/2016 07:53 PM, Dave Jones wrote: > > > On Mon, Jan 25, 2016 at 05:03:48PM +0300, Andrey Ryabinin wrote: > > > > 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 ? > > > > > Try to disable instrumentation for early code, like in the patch bellow. > > > > > > diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile > > index b1b78ff..d39a954 100644 > > --- a/arch/x86/kernel/Makefile > > +++ b/arch/x86/kernel/Makefile > > @@ -20,6 +20,8 @@ KASAN_SANITIZE_head$(BITS).o := n > > KASAN_SANITIZE_dumpstack.o := n > > KASAN_SANITIZE_dumpstack_$(BITS).o := n > > > > +UBSAN_SANITIZE := n > > + > > CFLAGS_irq.o := -I$(src)/../include/asm/trace > > > > obj-y := process_$(BITS).o signal.o > > This didn't help. > > > Also send me you .config please. Perhaps I will be able to reproduce this. > > below. Though I diffed a similar config from a machine where UBSAN works, > and the only differences seemed to be mostly benign stuff or hw specific drivers. > So after I enabled UBSAN_ALIGNMENT in your config, the kernel didn't boot. That is because unaligned access happens before lockdep_init() so ubsan callback takes the spinlock before locked_init() which is not allowed. As far as I understood most of your machines doesn't boot even without UBSAN_ALIGNMENT. So I'm guessing it might be similar problem. Could you try it without CONFIG_DEBUG_LOCKDEP? Or alternatively with patch like this: diff --git a/lib/ubsan.c b/lib/ubsan.c index 8799ae5..220e9d9 100644 --- a/lib/ubsan.c +++ b/lib/ubsan.c @@ -146,13 +146,13 @@ static bool location_is_valid(struct source_location *loc) return loc->file_name != NULL; } -static DEFINE_SPINLOCK(report_lock); +//static DEFINE_SPINLOCK(report_lock); static void ubsan_prologue(struct source_location *location, unsigned long *flags) { current->in_ubsan++; - spin_lock_irqsave(&report_lock, *flags); +// spin_lock_irqsave(&report_lock, *flags); pr_err("========================================" "========================================\n"); @@ -164,7 +164,7 @@ static void ubsan_epilogue(unsigned long *flags) dump_stack(); pr_err("========================================" "========================================\n"); - spin_unlock_irqrestore(&report_lock, *flags); +// spin_unlock_irqrestore(&report_lock, *flags); current->in_ubsan--; }