В комментарии показан ещё интересный способ сделать страницу RAM записываемой:Olej писал(а): Одним из сложных элементов при модификации системного вызова является запись в readonly страницу RAM (которая контролируется аппаратно MMU).
Код: Выделить всё
static void mem_setrw(void **table) {
unsigned int l;
pte_t *pte;
pte = lookup_address((long unsigned int)table, &l);
pte->pte |= _PAGE_RW;
}
static void mem_setro(void **table) {
unsigned int l;
pte_t *pte;
pte = lookup_address((long unsigned int)table, &l);
pte->pte &= ~_PAGE_RW;
}
http://lxr.free-electrons.com/source/ar ... le_types.htable — это адрес памяти, в котором нужно что-то сделать.
Код: Выделить всё
410 * Helper function that returns the kernel pagetable entry controlling
411 * the virtual address 'address'. NULL means no pagetable entry present.
412 * NOTE: the return type is pte_t but if the pmd is PSE then we return it
413 * as a pte too.
414 */
415 extern pte_t *lookup_address(unsigned long address, unsigned int *level);
Код: Выделить всё
395 enum pg_level {
396 PG_LEVEL_NONE,
397 PG_LEVEL_4K,
398 PG_LEVEL_2M,
399 PG_LEVEL_1G,
400 PG_LEVEL_NUM
401 };
Код: Выделить всё
7 typedef unsigned long pteval_t;
...
13 typedef union {
14 pteval_t pte;
15 pteval_t pte_low;
16 } pte_t;