Messages in this thread Patch in this message | | | Subject | Re: UBSAN: run-time undefined behavior sanity checker | From | Andrey Ryabinin <> | Date | Mon, 1 Feb 2016 19:08:46 +0300 |
| |
On 01/26/2016 07:53 PM, Dave Jones wrote: > <off-list because of huge config> > > 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--; }
| |