Re: [PATCH V9] RO/NX protection for loadable kernel modules

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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-next" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel]     [Linux USB Development]     [Yosemite News]     [Linux SCSI]

  Powered by Linux