linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: matthieu castet <castet.matthieu@free.fr>
To: Xiaotian Feng <xtfeng@gmail.com>
Cc: Valdis.Kletnieks@vt.edu, Ingo Molnar <mingo@elte.hu>,
	Kees Cook <kees.cook@canonical.com>,
	linux-kernel@vger.kernel.org,
	linux-security-module@vger.kernel.org,
	linux-next@vger.kernel.org,
	Arjan van de Ven <arjan@infradead.org>,
	James Morris <jmorris@namei.org>,
	Andrew Morton <akpm@linux-foundation.org>, Andi Kleen <ak@muc.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Rusty Russell <rusty@rustcorp.com.au>,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	Dave Jones <davej@redhat.com>,
	Siarhei Liakh <sliakh.lkml@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [PATCH 3/3 V13] RO/NX protection for loadable kernel
Date: Thu, 20 Jan 2011 21:32:00 +0100	[thread overview]
Message-ID: <4D389BC0.8080900@free.fr> (raw)
In-Reply-To: <AANLkTin55DXcQnK3NY7y-v8TXj5w-XT2rTJo9p90tj4g@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2455 bytes --]

Xiaotian Feng a écrit :
> On Thu, Dec 23, 2010 at 5:35 AM,  <Valdis.Kletnieks@vt.edu> wrote:
>> On Wed, 22 Dec 2010 13:40:19 +0100, Ingo Molnar said:
>>> * mat <castet.matthieu@free.fr> wrote:
>>>
>>>> Le Wed, 8 Dec 2010 14:19:51 -0800,
>>>> Kees Cook <kees.cook@canonical.com> a écrit :
>>>>
>>>>> On Fri, Nov 26, 2010 at 06:23:55PM +0100, mat wrote:
>>>>>> could you try the attached patch ?
>>>>>>
>>>>>> on module load, we sort the __jump_table section. So we should make
>>>>>> it writable.
>>>>>>
>>>>>>
>>>>>> Matthieu
>>>>>> diff --git a/arch/x86/include/asm/jump_label.h
>>>>>> b/arch/x86/include/asm/jump_label.h index f52d42e..574dbc2 100644
>>>>>> --- a/arch/x86/include/asm/jump_label.h
>>>>>> +++ b/arch/x86/include/asm/jump_label.h
>>>>>> @@ -14,7 +14,7 @@
>>>>>>         do
>>>>>> {                                                       \ asm
>>>>>> goto("1:"                                       \
>>>>>> JUMP_LABEL_INITIAL_NOP                  \
>>>>>> -                       ".pushsection __jump_table,  \"a\" \n\t"\
>>>>>> +                       ".pushsection __jump_table,  \"aw\" \n\t"\
>>>>>>                         _ASM_PTR "1b, %l[" #label "], %c0 \n\t" \
>>>>>>                         ".popsection \n\t"                      \
>>>>>>                         : :  "i" (key) :  : label);
>>>>>> \
>>>>> Acked-by: Kees Cook <kees.cook@canonical.com>
>>>>>
>>>>> Can this please get committed to tip?
>>>> I think it is not need anymore with  Steven Rostedt patch [1]
>>>>
>>>> Matthieu
>>>>
>>>> [1]
>>>>>> Here we set the text read only before we call the notifiers. The
>>>>>> function tracer changes the calls to mcount into nops via a notifier
>>>>>> call so this must be done after the module notifiers.
>>> What's the status of this bug?
>>>
>>> If we still need the patch then please submit it standalone with a proper subject
>>> line, with acks/signoffs added, etc.
>> Steve Rostedt's patch that moves the setting of the page permissions seems to
>> make this patch no longer necessary.  I tripped over this same issue, but the
>> version in the latest -mmotm does not need it, as it includes Steve's fix.
>>
> 
> I'm facing a boot failure (panic'ed on remove_jump_label_module_init)
> on 2.6.37 (latest commit 3c0cb7c), which is 100% reproducible.
> With this patch applied, I can boot my machine successfully, so I do
> think this patch is needed.
> 
Could you confirm that this patch fix the problem ?


Matthieu

[-- Attachment #2: 0001-Fix-jump-table-in-module-init-section.patch --]
[-- Type: text/x-diff, Size: 1145 bytes --]

>From 0eeba453aaba0ebff86f0a7ad9bfb8afbde0c0dc Mon Sep 17 00:00:00 2001
From: Matthieu CASTET <castet.matthieu@free.fr>
Date: Thu, 20 Jan 2011 21:25:03 +0100
Subject: [PATCH] Fix jump table in module init section

If we use jump table in module init, there are marked
as removed in __jump_table section after init is done.

But we already applied ro permissions on the module, so
we can't modify a read only section (crash in
remove_jump_label_module_init).

Make the __jump_table section rw.

Signed-off-by: Matthieu CASTET <castet.matthieu@free.fr>
---
 arch/x86/include/asm/jump_label.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/include/asm/jump_label.h b/arch/x86/include/asm/jump_label.h
index f52d42e..574dbc2 100644
--- a/arch/x86/include/asm/jump_label.h
+++ b/arch/x86/include/asm/jump_label.h
@@ -14,7 +14,7 @@
 	do {							\
 		asm goto("1:"					\
 			JUMP_LABEL_INITIAL_NOP			\
-			".pushsection __jump_table,  \"a\" \n\t"\
+			".pushsection __jump_table,  \"aw\" \n\t"\
 			_ASM_PTR "1b, %l[" #label "], %c0 \n\t" \
 			".popsection \n\t"			\
 			: :  "i" (key) :  : label);		\
-- 
1.7.2.3


  parent reply	other threads:[~2011-01-20 20:32 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-16 21:35 [PATCH 3/3 V13] RO/NX protection for loadable kernel matthieu castet
2010-11-25  3:41 ` Valdis.Kletnieks
2010-11-26 17:23   ` mat
2010-11-29 16:59     ` Valdis.Kletnieks
2010-12-08 22:19     ` Kees Cook
2010-12-10 23:18       ` mat
2010-12-11  0:27         ` Kees Cook
     [not found]           ` <20101211115735.21b616fe@mat-laptop>
2010-12-11 23:15             ` Kees Cook
2010-12-22 12:40         ` Ingo Molnar
2010-12-22 21:35           ` Valdis.Kletnieks
2010-12-22 21:57             ` Ingo Molnar
2010-12-22 22:02               ` Steven Rostedt
2010-12-23  8:49                 ` Ingo Molnar
2010-12-23 15:01             ` Steven Rostedt
2010-12-24  1:43               ` Valdis.Kletnieks
2011-01-07  9:34             ` Xiaotian Feng
2011-01-07 13:04               ` Ingo Molnar
2011-01-08 11:24                 ` matthieu castet
2011-01-10 23:49                   ` Kees Cook
2011-01-11 22:42                     ` matthieu castet
2011-01-20 20:32               ` matthieu castet [this message]
2011-01-21  2:35                 ` Xiaotian Feng
2010-11-29 18:15 ` Steven Rostedt
2010-11-29 23:35   ` Rusty Russell
2010-11-30 14:46     ` Steven Rostedt
2010-12-01 13:36       ` Rusty Russell
2010-11-30 21:20   ` mat
2010-12-01  0:38     ` Steven Rostedt

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=4D389BC0.8080900@free.fr \
    --to=castet.matthieu@free.fr \
    --cc=Valdis.Kletnieks@vt.edu \
    --cc=ak@muc.de \
    --cc=akpm@linux-foundation.org \
    --cc=arjan@infradead.org \
    --cc=davej@redhat.com \
    --cc=hpa@zytor.com \
    --cc=jmorris@namei.org \
    --cc=kees.cook@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.org \
    --cc=rusty@rustcorp.com.au \
    --cc=sfr@canb.auug.org.au \
    --cc=sliakh.lkml@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=xtfeng@gmail.com \
    /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).