Skip to content

Commit a2d063a

Browse files
rostedtIngo Molnar
authored andcommitted
extable, core_kernel_data(): Make sure all archs define _sdata
A new utility function (core_kernel_data()) is used to determine if a passed in address is part of core kernel data or not. It may or may not return true for RO data, but this utility must work for RW data. Thus both _sdata and _edata must be defined and continuous, without .init sections that may later be freed and replaced by volatile memory (memory that can be freed). This utility function is used to determine if data is safe from ever being freed. Thus it should return true for all RW global data that is not in a module or has been allocated, or false otherwise. Also change core_kernel_data() back to the more precise _sdata condition and document the function. Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Acked-by: Ralf Baechle <ralf@linux-mips.org> Acked-by: Hirokazu Takata <takata@linux-m32r.org> Cc: Richard Henderson <rth@twiddle.net> Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru> Cc: Matt Turner <mattst88@gmail.com> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Roman Zippel <zippel@linux-m68k.org> Cc: linux-m68k@lists.linux-m68k.org Cc: Kyle McMartin <kyle@mcmartin.ca> Cc: Helge Deller <deller@gmx.de> Cc: JamesE.J.Bottomley <jejb@parisc-linux.org> Link: http://lkml.kernel.org/r/1305855298.1465.19.camel@gandalf.stny.rr.com Signed-off-by: Ingo Molnar <mingo@elte.hu> ---- arch/alpha/kernel/vmlinux.lds.S | 1 + arch/m32r/kernel/vmlinux.lds.S | 1 + arch/m68k/kernel/vmlinux-std.lds | 2 ++ arch/m68k/kernel/vmlinux-sun3.lds | 1 + arch/mips/kernel/vmlinux.lds.S | 1 + arch/parisc/kernel/vmlinux.lds.S | 3 +++ kernel/extable.c | 12 +++++++++++- 7 files changed, 20 insertions(+), 1 deletion(-)
1 parent c16dbd5 commit a2d063a

7 files changed

Lines changed: 20 additions & 1 deletion

File tree

‎arch/alpha/kernel/vmlinux.lds.S‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ SECTIONS
4646
__init_end = .;
4747
/* Freed after init ends here */
4848

49+
_sdata = .; /* Start of rw data section */
4950
_data = .;
5051
RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
5152

‎arch/m32r/kernel/vmlinux.lds.S‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ SECTIONS
4444
EXCEPTION_TABLE(16)
4545
NOTES
4646

47+
_sdata = .; /* Start of data section */
4748
RODATA
4849
RW_DATA_SECTION(32, PAGE_SIZE, THREAD_SIZE)
4950
_edata = .; /* End of data section */

‎arch/m68k/kernel/vmlinux-std.lds‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ SECTIONS
2525

2626
EXCEPTION_TABLE(16)
2727

28+
_sdata = .; /* Start of data section */
29+
2830
RODATA
2931

3032
RW_DATA_SECTION(16, PAGE_SIZE, THREAD_SIZE)

‎arch/m68k/kernel/vmlinux-sun3.lds‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ SECTIONS
2525
_etext = .; /* End of text section */
2626

2727
EXCEPTION_TABLE(16) :data
28+
_sdata = .; /* Start of rw data section */
2829
RW_DATA_SECTION(16, PAGE_SIZE, THREAD_SIZE) :data
2930
/* End of data goes *here* so that freeing init code works properly. */
3031
_edata = .;

‎arch/mips/kernel/vmlinux.lds.S‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ SECTIONS
6565
NOTES :text :note
6666
.dummy : { *(.dummy) } :text
6767

68+
_sdata = .; /* Start of data section */
6869
RODATA
6970

7071
/* writeable */

‎arch/parisc/kernel/vmlinux.lds.S‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ SECTIONS
6969
/* End of text section */
7070
_etext = .;
7171

72+
/* Start of data section */
73+
_sdata = .;
74+
7275
RODATA
7376

7477
/* writeable */

‎kernel/extable.c‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,19 @@ int core_kernel_text(unsigned long addr)
7272
return 0;
7373
}
7474

75+
/**
76+
* core_kernel_data - tell if addr points to kernel data
77+
* @addr: address to test
78+
*
79+
* Returns true if @addr passed in is from the core kernel data
80+
* section.
81+
*
82+
* Note: On some archs it may return true for core RODATA, and false
83+
* for others. But will always be true for core RW data.
84+
*/
7585
int core_kernel_data(unsigned long addr)
7686
{
77-
if (addr >= (unsigned long)_stext &&
87+
if (addr >= (unsigned long)_sdata &&
7888
addr < (unsigned long)_edata)
7989
return 1;
8090
return 0;

0 commit comments

Comments
 (0)