allocate memory in userspace
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 9 lines · Timo Benk
I am a kernel newbie and i am writing a module. I need to allocate some memory in userspace because i want to access syscalls like
open(),lstat()etc. I need to call these methods in the kernel, and in my special case there is no other way, but i do not want to reimplement all the syscalls.I read that it should be possible, but i cannot find any example or recipe on how to do it.
mm_segment_t oldfs = get_fs();set_fs(KERNEL_DS);
ret = sys_yoursyscall(kernelargs ...)set_fs(oldfs);
Do not even think about using mmap or accessing sys_call_table for this. Your other post was so tasteless that it would be good if you retracted it with a followup because it would be very bad to have such an bad example in the l-k archives open to innocent search machine users uncommented.
-Andi
Quoted 9 lines · Andi Kleen
Quoted 7 lines · Timo Benk
I am a kernel newbie and i am writing a module. I need to allocate some memory in userspace because i want to access syscalls like
open(),lstat()etc. I need to call these methods in the kernel, and in my special case there is no other way, but i do not want to reimplement all the syscalls.
Quoted 7 lines
Quoted 2 lines
I read that it should be possible, but i cannot find any example or recipe on how to do it.
mm_segment_toldfs =get_fs();set_fs(KERNEL_DS);
ret =sys_yoursyscall(kernelargs ...)set_fs(oldfs);
Thank you very much for that hint.
Quoted 4 lines
Do not even think about using mmap or accessing
sys_call_tablefor this. Your other post was so tasteless that it would be good if you retracted it with a followup because it would be very bad to have such an bad example in the l-k archives open to innocent search machine users uncommented.
I will post a followup, but please tell me
a) a good doc for that topic where i can read why it is so bad
b) a reference for the do_mmap call
While searching through the ng archives i just found (lots of) hints that this can be done with mmap, so that was my approach to solve the problem.
Maybe it will be better that you (or any other) will comment what is so bad, as i told in my first post i am a newbie, so please keep that in mind.
-timo
Signature · 1 line
gpg key fingerprint = 6832 C8EC D823 4059 0CD1 6FBF 9383 7DBD 109E 98DC