linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Quentin Casasnovas <quentin.casasnovas@oracle.com>
To: Rusty Russell <rusty@rustcorp.com.au>,
	Guenter Roeck <linux@roeck-us.net>
Cc: lkml <linux-kernel@vger.kernel.org>,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	linux-next <linux-next@vger.kernel.org>
Subject: [PATCH 1/2] modpost: fix inverted logic in is_extable_fault_address().
Date: Wed, 15 Apr 2015 10:54:37 +0200	[thread overview]
Message-ID: <1429088078-23827-2-git-send-email-quentin.casasnovas@oracle.com> (raw)
In-Reply-To: <1429088078-23827-1-git-send-email-quentin.casasnovas@oracle.com>

As Guenter pointed out, we want to assert that extable_entry_size has been
discovered and not the other way around.  Moreover, this sanity check is
only valid when we're not dealing with the first relocation in __ex_table,
since we have not discovered the extable entry size at that point.

This was leading to a divide-by-zero on some architectures and make the
build fail.

Signed-off-by: Quentin Casasnovas <quentin.casasnovas@oracle.com>
Reported-by: Guenter Roeck <linux@roeck-us.net>
CC: Rusty Russell <rusty@rustcorp.com.au>
---
 scripts/mod/modpost.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 22dbc60..93bb87d 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1529,7 +1529,12 @@ static void find_extable_entry_size(const char* const sec, const Elf_Rela* r,
 }
 static inline bool is_extable_fault_address(Elf_Rela *r)
 {
-	if (!extable_entry_size == 0)
+	/*
+	 * extable_entry_size is only discovered after we've handled the
+	 * _second_ relocation in __ex_table, so only abort when we're not
+	 * handling the first reloc and extable_entry_size is zero.
+	 */
+	if (r->r_offset && extable_entry_size == 0)
 		fatal("extable_entry size hasn't been discovered!\n");
 
 	return ((r->r_offset == 0) ||
-- 
2.0.5

  reply	other threads:[~2015-04-15  8:52 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-14  8:42 linux-next: Tree for Apr 14 Stephen Rothwell
2015-04-14 16:11 ` linux-next: Tree for Apr 14 (crash due to modpost patch) Guenter Roeck
2015-04-14 16:36   ` Quentin Casasnovas
2015-04-14 16:50     ` Guenter Roeck
2015-04-15  8:54       ` [PATCH 0/2] Tentative fix for the divide-by-zero on score/paris/ Quentin Casasnovas
2015-04-15  8:54         ` Quentin Casasnovas [this message]
2015-04-15  8:54         ` [PATCH 2/2] modpost: fix extable entry size calculation Quentin Casasnovas
2015-04-15 13:26         ` [PATCH 0/2] Tentative fix for the divide-by-zero on score/paris/ Guenter Roeck
2015-04-15 13:46           ` Quentin Casasnovas
2015-04-15 15:31             ` Guenter Roeck
2015-04-15 16:49               ` Quentin Casasnovas
2015-04-15 21:19           ` Quentin Casasnovas
2015-04-15 21:32             ` Guenter Roeck
2015-04-16  1:43             ` Guenter Roeck
2015-04-16  3:49               ` Rusty Russell
2015-04-16  8:21               ` Quentin Casasnovas
2015-04-16 12:47                 ` Guenter Roeck
2015-04-16 13:58                   ` Quentin Casasnovas
2015-04-18  5:52                   ` Guenter Roeck
2015-04-19 11:47                     ` 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=1429088078-23827-2-git-send-email-quentin.casasnovas@oracle.com \
    --to=quentin.casasnovas@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=rusty@rustcorp.com.au \
    --cc=sfr@canb.auug.org.au \
    /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;
as well as URLs for NNTP newsgroup(s).