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 <[email protected]>
> Fixes: 19d436268dde ("debug: Add _ONCE() logic to report_bug()")
> Signed-off-by: Josh Poimboeuf <[email protected]>
> ---

> 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!

Reply via email to