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


Groups > linux.kernel > #1689079

Re: [PATCH] debug: fix WARN_ON_ONCE() for modules

From Peter Zijlstra <peterz@infradead.org>
Newsgroups linux.kernel
Subject Re: [PATCH] debug: fix WARN_ON_ONCE() for modules
Date 2017-07-17 16:10 +0200
Message-ID <u4eSJ-65Z-17@gated-at.bofh.it> (permalink)
References <u3nEJ-5Nf-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sat, Jul 15, 2017 at 12:10:58AM -0500, Josh Poimboeuf wrote:
> Mike Galbraith reported a situation where a WARN_ON_ONCE() call in DRM
> code turned into an oops.  As it turns out, WARN_ON_ONCE() seems to be
> completely broken when called from a module.
> 
> The bug was introduced with the following commit:
> 
>   19d436268dde ("debug: Add _ONCE() logic to report_bug()")
> 
> That commit changed WARN_ON_ONCE() to move its 'once' logic into the bug
> trap handler.  It requires a writable bug table so that the BUGFLAG_DONE
> bit can be written to the flags to indicate the first warning has
> occurred.
> 
> The bug table was made writable for vmlinux, which relies on
> vmlinux.lds.S and vmlinux.lds.h for laying out the sections.  However,
> it wasn't made writable for modules, which rely on the ELF section
> header flags.
> 
> Reported-by: Mike Galbraith <efault@gmx.de>
> Fixes: 19d436268dde ("debug: Add _ONCE() logic to report_bug()")
> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
> ---

> diff --git a/arch/x86/include/asm/bug.h b/arch/x86/include/asm/bug.h
> index 39e702d..aa6b202 100644
> --- a/arch/x86/include/asm/bug.h
> +++ b/arch/x86/include/asm/bug.h
> @@ -35,7 +35,7 @@
>  #define _BUG_FLAGS(ins, flags)						\
>  do {									\
>  	asm volatile("1:\t" ins "\n"					\
> -		     ".pushsection __bug_table,\"a\"\n"			\
> +		     ".pushsection __bug_table,\"aw\"\n"		\
>  		     "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n"	\
>  		     "\t"  __BUG_REL(%c0) "\t# bug_entry::file\n"	\
>  		     "\t.word %c1"        "\t# bug_entry::line\n"	\
> @@ -52,7 +52,7 @@ do {									\
>  #define _BUG_FLAGS(ins, flags)						\
>  do {									\
>  	asm volatile("1:\t" ins "\n"					\
> -		     ".pushsection __bug_table,\"a\"\n"			\
> +		     ".pushsection __bug_table,\"aw\"\n"		\
>  		     "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n"	\
>  		     "\t.word %c0"        "\t# bug_entry::flags\n"	\
>  		     "\t.org 2b+%c1\n"					\


Ah shiny. Thanks Josh!

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


Thread

[PATCH] debug: fix WARN_ON_ONCE() for modules Josh Poimboeuf <jpoimboe@redhat.com> - 2017-07-15 07:20 +0200
  Re: [PATCH] debug: fix WARN_ON_ONCE() for modules Mike Galbraith <efault@gmx.de> - 2017-07-15 08:40 +0200
    Re: [PATCH] debug: fix WARN_ON_ONCE() for modules Josh Poimboeuf <jpoimboe@redhat.com> - 2017-07-15 15:30 +0200
  Re: [PATCH] debug: fix WARN_ON_ONCE() for modules Masami Hiramatsu <mhiramat@kernel.org> - 2017-07-16 12:00 +0200
  Re: [PATCH] debug: fix WARN_ON_ONCE() for modules Peter Zijlstra <peterz@infradead.org> - 2017-07-17 16:10 +0200

csiph-web