Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755283AbbDNMO0 (ORCPT ); Tue, 14 Apr 2015 08:14:26 -0400 Received: from mail-pd0-f178.google.com ([209.85.192.178]:34572 "EHLO mail-pd0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753541AbbDNMOT (ORCPT ); Tue, 14 Apr 2015 08:14:19 -0400 Date: Tue, 14 Apr 2015 14:14:14 +0200 From: Thierry Reding To: Quentin Casasnovas Cc: lkml , Oleg Nesterov , Borislav Petkov , Linus Torvalds , Rusty Russell Subject: Re: [PATCH 7/7] modpost: handle relocations mismatch in __ex_table. Message-ID: <20150414121405.GA30442@ulmo.nvidia.com> References: <1426596002-26128-1-git-send-email-quentin.casasnovas@oracle.com> <1426596002-26128-8-git-send-email-quentin.casasnovas@oracle.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="wq9mPyueHGvFACwf" Content-Disposition: inline In-Reply-To: <1426596002-26128-8-git-send-email-quentin.casasnovas@oracle.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4657 Lines: 116 --wq9mPyueHGvFACwf Content-Type: multipart/mixed; boundary="bp/iNruPH9dso1Pn" Content-Disposition: inline --bp/iNruPH9dso1Pn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Mar 17, 2015 at 01:40:02PM +0100, Quentin Casasnovas wrote: > __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. >=20 > If one of these addresses point to a non-executable section, something is > seriously wrong since it either means the kernel will never fault from > there or it will not be able to jump to there. As both cases are serious > enough, we simply error out in these cases so the build fails and the > developper has to fix the issue. >=20 > In case the section is executable, but it isn't referenced in our list of > authorized sections to point to from __ex_table, we just dump a warning > giving more information about it. We do this in case the new section is > executable but isn't supposed to be executed by the kernel. This happened > with .altinstr_replacement, which is executable but is only used to copy > instructions from - we should never have our instruction pointer pointing > in .altinstr_replacement. Admitedly, a proper fix in that case would be = to > just set .altinstr_replacement NX, but we need to warn about future cases > like this. >=20 > Signed-off-by: Quentin Casasnovas > --- > scripts/mod/modpost.c | 141 ++++++++++++++++++++++++++++++++++++++++++++= ++++++ > 1 file changed, 141 insertions(+) This causes a bunch of mismatch warnings on 32-bit and 64-bit ARM because there are two additional sections, .text.fixup and =2Eexception.text that store executable code. I've attached a patch to fix those, but feel free to squash that into the original commit if that's still possible. Also adding Rusty since he applied this to the modules-next tree. Thierry --bp/iNruPH9dso1Pn Content-Type: text/x-diff; charset=us-ascii Content-Disposition: inline; filename="0001-modpost-Whitelist-.text.fixup-and-.exception.text.patch" Content-Transfer-Encoding: quoted-printable =46rom f5199120caafa0056cb18808ffe15af41bb102f3 Mon Sep 17 00:00:00 2001 =46rom: Thierry Reding Date: Tue, 14 Apr 2015 13:59:07 +0200 Subject: [PATCH] modpost: Whitelist .text.fixup and .exception.text 32-bit and 64-bit ARM use these sections to store executable code, so they must be whitelisted in modpost's table of valid text sections. Signed-off-by: Thierry Reding --- scripts/mod/modpost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index cbd53e08769d..6a925f200b25 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -876,7 +876,7 @@ static void check_section(const char *modname, struct e= lf_info *elf, #define TEXT_SECTIONS ".text", ".text.unlikely", ".sched.text", \ ".kprobes.text" #define OTHER_TEXT_SECTIONS ".ref.text", ".head.text", ".spinlock.text", \ - ".fixup", ".entry.text" + ".fixup", ".entry.text", ".text.fixup", ".exception.text" =20 #define INIT_SECTIONS ".init.*" #define MEM_INIT_SECTIONS ".meminit.*" --=20 2.3.5 --bp/iNruPH9dso1Pn-- --wq9mPyueHGvFACwf Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABCAAGBQJVLQSJAAoJEN0jrNd/PrOhvM8QAIc6SjDnit54vcCjqH+uNbTA Ia8jTeG9o+FEZoioZSc+tNQzK8T8Ovua4XqCEqY2au84+6rc50ydBruzIrYDkqGu VXSUTkDydxsYLK54YNLkTvVtrUqHVTfHymMNkbroj1LD2d5+hbNEYOHRr5t7gxfc DVY00Ilqdmjq4UsR0nbG5OIhsc+zlr9fDSOQ7faXHXhbvP+xB0Bcex4NDC/OamTX tEkWz7NFfsTTw7PbOS05V1N5Geg+TujQl7PwwcbxipNP8Z+XEzdzvZ237avyAVQC IUPUYtbGiTuYz05hn6EJI7XhgHm1V1PY3NR4VO7W+8DwElE+om43VKIf+Kv3RL0G bw6iAU0mBs3w0J/4/X+TKiyp33xWk1f8TxOOhO9pZV5g1Duuf7xLSnLn1X8CF6MO ncntpL58aUXtSWbx8ZIebPd85MoJfxK2cdYaRT9l0RX47yB+ZumoU8r++7LUlDWn qbdSGPNwVTHn0gUc0+rXj/hWZWFSsXIyRwHtbZf5sjgcB2fFP3/W50tSwBGmEaK4 KiioVJn+CZU+5LN60BXpx8F+bt2r4C0/Yf1cHX/wbdk87XQyaCEkHLXDQTk8A9mb ZGooy4PIKCXrw/C2ojzTBkpxVx9ABxYEuFtkfie+S5lOVvhF9cXUAbB3Miqz4Cy3 lAOM1FMCPH+W+fo740/x =tXEK -----END PGP SIGNATURE----- --wq9mPyueHGvFACwf-- -- 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/