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


Groups > linux.kernel > #1323278 > unrolled thread

Re: UBSAN: run-time undefined behavior sanity checker

Started byAndrey Ryabinin <aryabinin@virtuozzo.com>
First post2016-02-01 17:10 +0100
Last post2016-02-01 23:20 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  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

#1323278 — Re: UBSAN: run-time undefined behavior sanity checker

FromAndrey Ryabinin <aryabinin@virtuozzo.com>
Date2016-02-01 17:10 +0100
SubjectRe: UBSAN: run-time undefined behavior sanity checker
Message-ID<qXpd8-5p0-21@gated-at.bofh.it>
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--;
 }
 

[toc] | [next] | [standalone]


#1323568

FromDave Jones <davej@codemonkey.org.uk>
Date2016-02-01 23:20 +0100
Message-ID<qXuZb-112-5@gated-at.bofh.it>
In reply to#1323278
On Mon, Feb 01, 2016 at 07:08:46PM +0300, Andrey Ryabinin wrote:

 > >  > > 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.
 > > This didn't help.
 > 
 > 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.
 
 > Could you try it without CONFIG_DEBUG_LOCKDEP?
 > Or alternatively with patch like this:

Tried with the patch, seems to work fine now.

thanks,
	Dave

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web