Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1323278

Re: UBSAN: run-time undefined behavior sanity checker

From Andrey Ryabinin <aryabinin@virtuozzo.com>
Newsgroups linux.kernel
Subject Re: UBSAN: run-time undefined behavior sanity checker
Date 2016-02-01 17:10 +0100
Message-ID <qXpd8-5p0-21@gated-at.bofh.it> (permalink)
References (1 earlier) <qTCiB-7Lx-1@gated-at.bofh.it> <qTN4o-6Dx-39@gated-at.bofh.it> <qTNnJ-73X-27@gated-at.bofh.it> <qUQ0a-54G-19@gated-at.bofh.it> <qXpd9-5p0-23@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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--;
 }
 

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: UBSAN: run-time undefined behavior sanity checker Andrey Ryabinin <aryabinin@virtuozzo.com> - 2016-02-01 17:10 +0100
  Re: UBSAN: run-time undefined behavior sanity checker Dave Jones <davej@codemonkey.org.uk> - 2016-02-01 23:20 +0100

csiph-web