[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <201002020819.55499.rusty@rustcorp.com.au>
Date: Tue, 2 Feb 2010 08:19:55 +1030
From: Rusty Russell <rusty@...tcorp.com.au>
To: Siarhei Liakh <sliakh.lkml@...il.com>
Cc: linux-kernel@...r.kernel.org,
linux-security-module@...r.kernel.org, linux-next@...r.kernel.org,
Arjan van de Ven <arjan@...radead.org>,
James Morris <jmorris@...ei.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Andi Kleen <ak@....de>, Thomas Gleixner <tglx@...utronix.de>,
"H. Peter Anvin" <hpa@...or.com>, Ingo Molnar <mingo@...e.hu>,
Stephen Rothwell <sfr@...b.auug.org.au>,
Dave Jones <davej@...hat.com>
Subject: Re: [PATCH V9] RO/NX protection for loadable kernel modules
On Tue, 2 Feb 2010 02:59:41 am Siarhei Liakh wrote:
> V9: coding style fixes
But not compile tested:
> +void set_page_attributes(void *start, void *end,
> + void (*set)(unsigned long start, int num_pages))
> +{
> + unsigned long begin_pfn = PFN_DOWN((unsigned long)start);
> + unsigned long end_pfn = PFN_DOWN((unsigned long)end);
> + if (end_pfn > begin_pfn)
> + set(begin_pfn << PAGE_SHIFT, end_pfn - begin_pfn);
> +}
...
> + if (ro_size > 0) {
> + set_page_attributes((unsigned long)base,
> + (unsigned long)base + ro_size,
> + set_memory_ro);
The casts here should cause a warning.
> + if (total_size > text_size) {
> + begin_pfn = PFN_UP((unsigned long)base + text_size);
> + end_pfn = PFN_UP((unsigned long)base + total_size);
> + if (end_pfn > begin_pfn)
> + set_memory_nx(begin_pfn << PAGE_SHIFT,
> + end_pfn - begin_pfn);
Use the helper here too?
> + if ((mod->module_core) && (mod->core_text_size)) {
> + set_page_attributes((unsigned long)mod->module_core,
> + (unsigned long)mod->module_core
> + + mod->core_text_size,
> + set_memory_rw);
> + }
> + if ((mod->module_init) && (mod->init_text_size)) {
> + set_page_attributes((unsigned long)mod->module_init,
> + (unsigned long)mod->module_init
> + + mod->init_text_size,
> + set_memory_rw);
More unwanted casts...
> + set_page_attributes((unsigned long)mod->module_core,
> + (unsigned long)mod->module_core
> + + mod->core_text_size,
> + set_memory_ro);
> + }
> + if ((mod->module_init) && (mod->init_text_size)) {
> + set_page_attributes((unsigned long)mod->module_init,
> + (unsigned long)mod->module_init
> + + mod->init_text_size,
> + set_memory_ro);
Here, too.
Thanks,
Rusty.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists