From: Siarhei Liakh <sliakh.lkml@gmail.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: James Morris <jmorris@namei.org>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org,
linux-security-module@vger.kernel.org,
Arjan van de Ven <arjan@infradead.org>, Andi Kleen <ak@muc.de>,
Rusty Russell <rusty@rustcorp.com.au>,
Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH] RO/NX protection for loadable kernel modules
Date: Wed, 24 Jun 2009 11:53:32 -0400 [thread overview]
Message-ID: <817ecb6f0906240853jcfa96dep336bda6892fe7ebe@mail.gmail.com> (raw)
In-Reply-To: <20090623100040.GD30634@elte.hu>
On Tue, Jun 23, 2009 at 6:00 AM, Ingo Molnar<mingo@elte.hu> wrote:
>
> * James Morris <jmorris@namei.org> wrote:
>
>> On Thu, 18 Jun 2009, Siarhei Liakh wrote:
>>
>> > This patch is a logical extension of the protection provided by
>> > CONFIG_DEBUG_RODATA to LKMs. The protection is provided by splitting
>> > module_core and module_init into three logical parts each and setting
>> > appropriate page access permissions for each individual section:
>> >
>> > 1. Code: RO+X
>> > 2. RO data: RO+NX
>> > 3. RW data: RW+NX
>> >
>> > In order to achieve proper protection, layout_sections() have been
>> > modified to align each of the three parts mentioned above onto page
>> > boundary. Next, the corresponding page access permissions are set
>> > right before successful exit from load_module(). Further,
>> > module_free() have been modified to set module_core or module_init as
>> > RW+NX right before calling vfree(). Functionality of this patch is
>> > enabled only when CONFIG_DEBUG_RODATA defined at compile time.
>> >
>>
>> This looks potentially useful to me, but I'm not an x86 expert
>> (several now added to Cc:).
>
> Pinged a few folks about this already. It looks useful, with the
> main worry being:
>
> 1) the increase in effective module size (probably worth the price)
> 2) some uglies in the patch (fixable)
>
> The main ugliness is the excessive use of #ifdefs - those should be
> eliminated. Also, most scripts/checkpatch.pl warnings about this
> patch should be taken seriously.
>
> Ingo
1: You are correct. This patch effectively sets the lower limit of 3
pages for a module (well, there are some modules that do not have
.text and/or .data, but we are not talking about these extremes). So,
for small (sub-one-page) modules this will create 300% overhead.
However, for large modules the overhead is not that significant.
2: Agree. Will fix.
The main reason the #ifdefs are there is to make this patch dependent
on CONFIG_DEBUG_RODATA, since not everyone may be willing to pay 300%
overhead for the modules they use. I guess I could do some code
re-factoring, but #ifdefs will still be there. Or did you really mean
to eliminate all of them, making this patch a permanent feature of the
kernel? Can you please point me into right direction on how to
eliminate the #ifdefs while allowing to exclude the patch at compile
time if necessary?
Thanks.
prev parent reply other threads:[~2009-06-24 15:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-19 1:33 [PATCH] RO/NX protection for loadable kernel modules Siarhei Liakh
2009-06-23 2:43 ` James Morris
2009-06-23 10:00 ` Ingo Molnar
2009-06-24 15:53 ` Siarhei Liakh [this message]
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=817ecb6f0906240853jcfa96dep336bda6892fe7ebe@mail.gmail.com \
--to=sliakh.lkml@gmail.com \
--cc=ak@muc.de \
--cc=akpm@linux-foundation.org \
--cc=arjan@infradead.org \
--cc=hpa@zytor.com \
--cc=jmorris@namei.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rusty@rustcorp.com.au \
--cc=tglx@linutronix.de \
/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