c - control a function pointer in the kernel -
if have controlled function pointer in kernel pointing somewhere want, let's make point own designed function evil
in user land.
err = writepage(page) //->writepage kernel function pointer pointing evil in userland
there printf
in evil
, there kernel panic if kernel dereferences function pointer? since evil
runs in kernel mode (correct me if i'm wrong), kernel not printf
is.
int evil() { printf("i don't think printf executed because evil executed kernel mode") }
the kernel never sees "printf
"; sees call different address, program doesn't call function name, sets registers containing parameters accordingly , calls function.
that won't work, because address printf
call points relative userland process' memory, , doesn't exist in kernel memory.
you have realize processes run in virtual memory of own -- none of addresses used in program need make sense different process.
so can't call function in userland process; you'd first have find out in memory kernel sees it, , call it. of course, it'd run in kernel mode, that's not surprising -- no sane os allow userland process bend internal function calls in manner.
Comments
Post a Comment