Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754116AbbDMLcD (ORCPT ); Mon, 13 Apr 2015 07:32:03 -0400 Received: from ozlabs.org ([103.22.144.67]:39730 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753296AbbDMLb5 convert rfc822-to-8bit (ORCPT ); Mon, 13 Apr 2015 07:31:57 -0400 From: Rusty Russell To: Quentin Casasnovas , lkml Cc: Oleg Nesterov , Borislav Petkov , Linus Torvalds , Quentin Casasnovas Subject: Re: [PATCH 7/7] modpost: handle relocations mismatch in __ex_table. In-Reply-To: <1426596002-26128-8-git-send-email-quentin.casasnovas@oracle.com> References: <1426596002-26128-1-git-send-email-quentin.casasnovas@oracle.com> <1426596002-26128-8-git-send-email-quentin.casasnovas@oracle.com> User-Agent: Notmuch/0.17 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu) Date: Mon, 13 Apr 2015 20:48:56 +0930 Message-ID: <87r3rotgwv.fsf@rustcorp.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4146 Lines: 85 Quentin Casasnovas writes: > __ex_table is a simple table section where each entry is a pair of > addresses - the first address is an address which can fault in kernel > space, and the second address points to where the kernel should jump to > when handling that fault. This is how copy_from_user() does not crash the > kernel if userspace gives a borked pointer for example. Warnings on 32-bit: scripts/mod/modpost.c:1562:7: warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘Elf32_Addr’ [-Wformat=] to_pretty_name, tosec, tosym_name, to_pretty_name_p); ^ scripts/mod/modpost.c:1574:4: warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘Elf32_Addr’ [-Wformat=] fromsec, r->r_offset, tosec, tosec, tosec); ^ scripts/mod/modpost.c: In function ‘extable_mismatch_handler’: scripts/mod/modpost.c:1596:9: warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘Elf32_Addr’ [-Wformat=] fromsec, r->r_offset, tosec, modname); ^ scripts/mod/modpost.c:1604:10: warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘Elf32_Addr’ [-Wformat=] fromsec, r->r_offset, tosec); ^ scripts/mod/modpost.c:1611:10: warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘Elf32_Addr’ [-Wformat=] fromsec, r->r_offset, tosec); ^ Fixed like so: diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 7b56ae567fba..b495547e321f 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1557,7 +1557,7 @@ static void report_extable_warnings(const char* modname, struct elf_info* elf, warn("%s(%s+0x%lx): Section mismatch in reference" " from the %s %s%s to the %s %s:%s%s\n", - modname, fromsec, r->r_offset, from_pretty_name, + modname, fromsec, (long)r->r_offset, from_pretty_name, fromsym_name, from_pretty_name_p, to_pretty_name, tosec, tosym_name, to_pretty_name_p); @@ -1571,7 +1571,7 @@ static void report_extable_warnings(const char* modname, struct elf_info* elf, "list of authorized sections to jump to on fault.\n" "This can be achieved by adding \"%s\" to \n" "OTHER_TEXT_SECTIONS in scripts/mod/modpost.c.\n", - fromsec, r->r_offset, tosec, tosec, tosec); + fromsec, (long)r->r_offset, tosec, tosec, tosec); } static void extable_mismatch_handler(const char* modname, struct elf_info *elf, @@ -1593,7 +1593,7 @@ static void extable_mismatch_handler(const char* modname, struct elf_info *elf, "Something is seriously wrong and should be fixed.\n" "You might get more information about where this is\n" "coming from by using scripts/check_extable.sh %s\n", - fromsec, r->r_offset, tosec, modname); + fromsec, (long)r->r_offset, tosec, modname); else if (!is_executable_section(elf, get_secindex(elf, sym))) { if (is_extable_fault_address(r)) fatal("The relocation at %s+0x%lx references\n" @@ -1601,14 +1601,14 @@ static void extable_mismatch_handler(const char* modname, struct elf_info *elf, "it is not possible for the kernel to fault\n" "at that address. Something is seriously wrong\n" "and should be fixed.\n", - fromsec, r->r_offset, tosec); + fromsec, (long)r->r_offset, tosec); else fatal("The relocation at %s+0x%lx references\n" "section \"%s\" which is not executable, IOW\n" "the kernel will fault if it ever tries to\n" "jump to it. Something is seriously wrong\n" "and should be fixed.\n", - fromsec, r->r_offset, tosec); + fromsec, (long)r->r_offset, tosec); } } Thanks, Rusty. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/