From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751391AbdGQOAv (ORCPT ); Mon, 17 Jul 2017 10:00:51 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:36850 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751278AbdGQOAu (ORCPT ); Mon, 17 Jul 2017 10:00:50 -0400 Date: Mon, 17 Jul 2017 16:00:44 +0200 From: Peter Zijlstra To: Josh Poimboeuf Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Mike Galbraith Subject: Re: [PATCH] debug: fix WARN_ON_ONCE() for modules Message-ID: <20170717140044.c6ofg23crkcqd6ou@hirez.programming.kicks-ass.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Fixes: 19d436268dde ("debug: Add _ONCE() logic to report_bug()") > Signed-off-by: Josh Poimboeuf > --- > 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!