查看文章 |
新内核中较重要的一个选项
2009-07-07 16:35
因为这个选项, /dev/mem类型的rootkit很可能会再次发挥作用,它默认是没开启的。。。 kernel hacking -> Filter access to /dev/mem 不过rhel系列的内核已经开启了这个选项,所以还是很安全的。 大于1m的物理内存是不能被映射的, 因此想读内核空间是不可能的。 重新升级内核到2.6.30, 没开启filter选项, 又可以读写内核空间了。。。 看下代码/drivers/char/mem.c: /* * This funcion reads the *physical* memory. The f_pos points directly to the * memory location. */ static ssize_t read_mem(struct file * file, char __user * buf, size_t count, loff_t *ppos) { ... while (count > 0) { /* * Handle first page in case it's not aligned */ if (-p & (PAGE_SIZE - 1)) sz = -p & (PAGE_SIZE - 1); else sz = PAGE_SIZE; sz = min_t(unsigned long, sz, count); if (!range_is_allowed(p >> PAGE_SHIFT, count)) return -EPERM; .... } >> range_is_allowed #ifdef CONFIG_STRICT_DEVMEM static inline int range_is_allowed(unsigned long pfn, unsigned long size) { u64 from = ((u64)pfn) << PAGE_SHIFT; u64 to = from + size; u64 cursor = from; while (cursor < to) { if (!devmem_is_allowed(pfn)) { printk(KERN_INFO "Program %s tried to access /dev/mem between %Lx->%Lx.\n", current->comm, from, to); return 0; } cursor += PAGE_SIZE; pfn++; } return 1; } #else static inline int range_is_allowed(unsigned long pfn, unsigned long size) { return 1; } #endif >> devmem_is_allowed /* |
最近读者: