mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@ozlabs.org>
To: Quentin Casasnovas <quentin.casasnovas@oracle.com>,
	lkml <linux-kernel@vger.kernel.org>
Cc: Oleg Nesterov <oleg@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Quentin Casasnovas <quentin.casasnovas@oracle.com>
Subject: Re: [PATCH 7/7] modpost: handle relocations mismatch in __ex_table.
Date: Mon, 13 Apr 2015 20:48:56 +0930	[thread overview]
Message-ID: <87r3rotgwv.fsf@rustcorp.com.au> (raw)
In-Reply-To: <1426596002-26128-8-git-send-email-quentin.casasnovas@oracle.com>

Quentin Casasnovas <quentin.casasnovas@oracle.com> 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.

  parent reply	other threads:[~2015-04-13 11:32 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-17 12:39 [PATCH 0/7] Detect future mis-uses of __ex_table section Quentin Casasnovas
2015-03-17 12:39 ` [PATCH 1/7] modpost: add strict white-listing when referencing sections Quentin Casasnovas
2015-03-17 16:25   ` Linus Torvalds
2015-03-18  9:14     ` Quentin Casasnovas
2015-03-20  1:29   ` Rusty Russell
2015-04-13  9:04     ` Quentin Casasnovas
2015-04-13 11:19       ` Rusty Russell
2015-04-13 11:24       ` Rusty Russell
2015-03-17 12:39 ` [PATCH 2/7] modpost: add .sched.text and .kprobes.text to the TEXT_SECTIONS list Quentin Casasnovas
2015-03-18  9:08   ` Quentin Casasnovas
2015-03-17 12:39 ` [PATCH 3/7] modpost: add handler function pointer to sectioncheck Quentin Casasnovas
2015-03-18  9:08   ` Quentin Casasnovas
2015-03-17 12:39 ` [PATCH 4/7] modpost: factorize symbol pretty print in get_pretty_name() Quentin Casasnovas
2015-03-18  9:08   ` Quentin Casasnovas
2015-03-17 12:40 ` [PATCH 5/7] modpost: mismatch_handler: retrieve tosym information only when needed Quentin Casasnovas
2015-03-18  9:09   ` Quentin Casasnovas
2015-03-17 12:40 ` [PATCH 6/7] scripts: add check_extable.sh script Quentin Casasnovas
2015-03-18  9:09   ` Quentin Casasnovas
2015-03-17 12:40 ` [PATCH 7/7] modpost: handle relocations mismatch in __ex_table Quentin Casasnovas
2015-03-18  9:09   ` Quentin Casasnovas
2015-04-13 11:18   ` Rusty Russell [this message]
2015-04-13 13:33     ` Quentin Casasnovas
2015-04-14 12:14   ` Thierry Reding
2015-04-14 12:35     ` Quentin Casasnovas
2015-04-15  3:27       ` Rusty Russell
2015-04-15  8:35         ` Quentin Casasnovas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r3rotgwv.fsf@rustcorp.com.au \
    --to=rusty@ozlabs.org \
    --cc=bp@alien8.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=quentin.casasnovas@oracle.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome