Writable sys_call_table (was: Re: [uClinux-dev] [PATCH] m68k: Merge mmu and non-mmu versions of sys_call_table)

Geert Uytterhoeven
2011-04-13T18:05:25Z

On Thu, Apr 7, 2011 at 10:29, Andreas Schwab <schwab@linux-m68k.org> wrote:
> Geert Uytterhoeven <geert@linux-m68k.org> writes:
>> Isn't there a reason it was read-write on m68k, like the table may be changed
>> at runtime (to install rootkits :-)? Have to check what the other arches do...
>
> Initially the syscall_table in Linux has always been writable, bb152f53
> ("x86/x86_64: mark rodata section read-only: make some datastructures
> const") made it read-only on x86.  Apparently nobody bothered to do the
> equivalent change on m68k (I don't think anything makes the kernel text
> segment write protected anyway).

11 arches still store it in "data", including the 4 using the new
asm-generic/unistd.h
framework. 9 use "rodata" and 6 use "text".
The constness of C "extern" declarations doesn't necessarily matches the
actual sections.

alpha: .data
arm: presumably .text?
avr32: .section .rodata,"a",@progbits
blackfin: .section .l1.data / .data
cris: .section .rodata,"a"
frv: .section .rodata
h8300: .section .text
ia64: .rodata
extern unsigned long sys_call_table[NR_syscalls];
m32r: .section .rodata,"a"
m68k: .data (mmu), .text (nommu)
m68knommu: .text
microblaze: .section .rodata,"a"
mips: presumably .text?
mn10300: .data
extern const unsigned long sys_call_table[];
parisc: .section .rodata,"a"
powerpc: presumably .text?
extern unsigned long *sys_call_table;
static void *spu_syscall_table[] (SPU in CBEA)
s390: .section .rodata, "a"
extern const unsigned int sys_call_table[];
score: void *sys_call_table[__NR_syscalls[] = { ... }
sh: .data
extern const unsigned long sys_call_table[];
sh64: .section .data, "aw"
sparc: .data
extern const unsigned int sys_call_table[];
sparc64: .text
tile: void *sys_call_table[__NR_syscalls] = { ... }
void *compat_sys_call_table[__NR_syscalls] = { ... }
um: extern syscall_handler_t *sys_call_table[];
unicore32: void *sys_call_table[__NR_syscalls] = { ... }
x86: .section .rodata,"a"
extern const unsigned long sys_call_table[];
const sys_call_ptr_t
sys_call_table[__NR_syscall_max+1] = { ... }
xtensa: syscall_t sys_call_table[__NR_syscall_count] = { ... }

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds