Allow DEBUG_RODATA and KPROBES to co-exist
Do not mark the kernel text read only if KPROBES is in the kernel; kprobes needs to hot-patch the kernel text to insert it's instrumentation. In this case, only mark the .rodata segment as read only. Signed-off-by: Arjan van de Ven <arjan@linux.intel.com> Tested-by: S. P. Prasanna <prasanna@in.ibm.com> Cc: Andi Kleen <ak@suse.de> Cc: William Cohen <wcohen@redhat.com> Cc: Ian McDonald <ian.mcdonald@jandi.co.nz> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Родитель
79d9a72f87
Коммит
0864a4e201
|
@ -49,7 +49,6 @@ config DEBUG_PAGEALLOC
|
||||||
config DEBUG_RODATA
|
config DEBUG_RODATA
|
||||||
bool "Write protect kernel read-only data structures"
|
bool "Write protect kernel read-only data structures"
|
||||||
depends on DEBUG_KERNEL
|
depends on DEBUG_KERNEL
|
||||||
depends on !KPROBES # temporary for 2.6.22
|
|
||||||
help
|
help
|
||||||
Mark the kernel read-only data as write-protected in the pagetables,
|
Mark the kernel read-only data as write-protected in the pagetables,
|
||||||
in order to catch accidental (and incorrect) writes to such const
|
in order to catch accidental (and incorrect) writes to such const
|
||||||
|
|
|
@ -799,6 +799,7 @@ void mark_rodata_ro(void)
|
||||||
unsigned long start = PFN_ALIGN(_text);
|
unsigned long start = PFN_ALIGN(_text);
|
||||||
unsigned long size = PFN_ALIGN(_etext) - start;
|
unsigned long size = PFN_ALIGN(_etext) - start;
|
||||||
|
|
||||||
|
#ifndef CONFIG_KPROBES
|
||||||
#ifdef CONFIG_HOTPLUG_CPU
|
#ifdef CONFIG_HOTPLUG_CPU
|
||||||
/* It must still be possible to apply SMP alternatives. */
|
/* It must still be possible to apply SMP alternatives. */
|
||||||
if (num_possible_cpus() <= 1)
|
if (num_possible_cpus() <= 1)
|
||||||
|
@ -808,7 +809,7 @@ void mark_rodata_ro(void)
|
||||||
size >> PAGE_SHIFT, PAGE_KERNEL_RX);
|
size >> PAGE_SHIFT, PAGE_KERNEL_RX);
|
||||||
printk("Write protecting the kernel text: %luk\n", size >> 10);
|
printk("Write protecting the kernel text: %luk\n", size >> 10);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
start += size;
|
start += size;
|
||||||
size = (unsigned long)__end_rodata - start;
|
size = (unsigned long)__end_rodata - start;
|
||||||
change_page_attr(virt_to_page(start),
|
change_page_attr(virt_to_page(start),
|
||||||
|
|
|
@ -9,7 +9,6 @@ source "lib/Kconfig.debug"
|
||||||
config DEBUG_RODATA
|
config DEBUG_RODATA
|
||||||
bool "Write protect kernel read-only data structures"
|
bool "Write protect kernel read-only data structures"
|
||||||
depends on DEBUG_KERNEL
|
depends on DEBUG_KERNEL
|
||||||
depends on !KPROBES # temporary for 2.6.22
|
|
||||||
help
|
help
|
||||||
Mark the kernel read-only data as write-protected in the pagetables,
|
Mark the kernel read-only data as write-protected in the pagetables,
|
||||||
in order to catch accidental (and incorrect) writes to such const data.
|
in order to catch accidental (and incorrect) writes to such const data.
|
||||||
|
|
|
@ -605,6 +605,11 @@ void mark_rodata_ro(void)
|
||||||
if (num_possible_cpus() > 1)
|
if (num_possible_cpus() > 1)
|
||||||
start = (unsigned long)_etext;
|
start = (unsigned long)_etext;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_KPROBES
|
||||||
|
start = (unsigned long)__start_rodata;
|
||||||
|
#endif
|
||||||
|
|
||||||
end = (unsigned long)__end_rodata;
|
end = (unsigned long)__end_rodata;
|
||||||
start = (start + PAGE_SIZE - 1) & PAGE_MASK;
|
start = (start + PAGE_SIZE - 1) & PAGE_MASK;
|
||||||
end &= PAGE_MASK;
|
end &= PAGE_MASK;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче