From: Arjan van de Ven <arjan@infradead.org>
To: Siarhei Liakh <sliakh.lkml@gmail.com>
Cc: linux-kernel@vger.kernel.org,
linux-security-module@vger.kernel.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>, Ingo Molnar <mingo@elte.hu>,
Rusty Russell <rusty@rustcorp.com.au>
Subject: Re: [PATCH v4] RO/NX protection for loadable kernel modules
Date: Tue, 7 Jul 2009 22:06:40 -0700 [thread overview]
Message-ID: <20090707220640.5352ac94@infradead.org> (raw)
In-Reply-To: <817ecb6f0907071747g1d3455cdy9eb84102c17c5ad0@mail.gmail.com>
On Tue, 7 Jul 2009 20:47:42 -0400
Siarhei Liakh <sliakh.lkml@gmail.com> wrote:
>
> The patch have been developed for Linux 2.6.30 by Siarhei Liakh
> <sliakh.lkml@gmail.com> and Xuxian Jiang <jiang@cs.ncsu.edu>.
>
> ---
>
> Signed-off-by: Siarhei Liakh <sliakh.lkml@gmail.com>
> Signed-off-by: Xuxian Jiang <jiang@cs.ncsu.edu>
I like it, you can already put
Acked-by: Arjan van de Ven <arjan@linux.intel.com>
there if you want. If you're going to make a v5 then I do have another
suggestion for improvement... (only possible now that the code is very
clean)
> + /* Set RO for module text and RO-data*/
> + if (ro_size > 0) {
> + begin_addr = (unsigned long) base;
> + end_addr = begin_addr + ro_size;
> +
> + /*skip last page if end address is not page-aligned*/
> + if (!IS_ALIGNED(end_addr, PAGE_SIZE))
> + end_addr = ALIGN(end_addr - PAGE_SIZE,PAGE_SIZE);
> +
> + /*Set text RO if there are still pages between begin
> and end*/
> + if (end_addr > begin_addr) {
> + pg_count = PFN_DOWN(end_addr - 1) -
> + PFN_DOWN(begin_addr) + 1;
> + DEBUGP(" RO: 0x%lx %lu\n", begin_addr,
> pg_count);
> + set_memory_ro(begin_addr, pg_count);
> + } else {
> + DEBUGP(" RO: less than a page, not
> enforcing.\n");
> + }
> + } else {
> + DEBUGP(" RO: section not present.\n");
> + }
I *think* this can be done as
begin_pfn = PFN_UP( (base);
end_pfn = PFN_DOWN(base + ro_size);
if (end_pfn > begin_pfn)
set_memory_ro(begin_pfn >> PAGE_SHIFT, end_pfn - begin_pfn);
(note that I think the +1 you have might be buggy)
if you use PFN_UP/PFN_DOWN like this (rounding the start up, rounding the end down),
then your entire "fix alignment" is not needed, the PFN rounding will automatically
take case of this.
similar construct also applies to the NX codepath that follows right after this RO codepath.
next prev parent reply other threads:[~2009-07-08 5:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-05 23:23 [PATCH v3] " Siarhei Liakh
2009-07-06 0:03 ` Arjan van de Ven
2009-07-06 1:13 ` Rusty Russell
2009-07-08 0:47 ` [PATCH v4] " Siarhei Liakh
2009-07-08 5:06 ` Arjan van de Ven [this message]
2009-07-08 22:31 ` Siarhei Liakh
2009-07-11 11:49 ` Rusty Russell
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=20090707220640.5352ac94@infradead.org \
--to=arjan@infradead.org \
--cc=ak@muc.de \
--cc=akpm@linux-foundation.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=sliakh.lkml@gmail.com \
--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
Powered by JetHome