Jumping to-and fro between Kernel and user code in Linux -


i doing kernel hacking on linux running x86-64 research project. kernel routine need jump user mode code page , return kernel code. in other words, need trampoline on user code while executing in kernel.

i wondering whether can @ possible or not. if possible, can give idea how can achieved?

it unlikely possible "easily".

without knowing application, , without suggesting rethink kernel<->app interface, possible hack work this: have application register piece of trampoline code kernel component passing address of code. trampoline code execute "real" user mode function, issue syscall or exception return kernel.

while not user-mode subroutine, gets reasonably close: when application calls whatever kernel function needs callback, kernel function can save real return address, change registered trampoline address , return user mode. trampoline call function, syscall/exception following kick kernel , can continue whatever doing there.

you don't need worry security anyway, if you'd have make sure "return trampoline" syscall accepted processes still have open trampoline hack going on.

you can take @ how signals work; having kernel interrupt application , having application invoke signal handler; signal-like implementation work without application having active syscall going on (but have limitations of signal handler).

in fact, maybe can use signal? again, take @ how signals work in kernel, , signal user-code. install appropiate signal handler in application, , have signal handler invoke "return userspace trampoline" syscall.

either way, sounds bit... hackish. without ever having done kernel stuff, assume interfacing application through device node, socket or similar mechanism better way... or have syscalls return "to do" result item application telling invoke siome user space code , report syscall.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -