mardi 9 décembre 2014

Can't find where __put_user_1 is defined


I have been going through the linux kernel module programming guide, and I decided to find out how put_user(*(msg_Ptr), buffer) works. After all macro expansion is done, it appears that this inline assembly will put __pu_val into the buffer in userspace. I have put this in my program.



asm volatile("call __put_user_1" : "=a" (__ret_pu) : "0" (__pu_val), "c" (buffer) : "ebx");


Looking through the kernel code, there only appears to be one mention of this __put_user_1 function, in /usr/src/linux-headers-3.13.0-37/arch/x86/include/asm/uaccess.h. This is just as an external function prototype:



/*
* Strange magic calling convention: pointer in %ecx,
* value in %eax(:%edx), return value in %eax. clobbers %rbx
*/
extern void __get_user_1(void);


I can't see where this is defined anywhere, but Module.symvers has the __get_user_1 symbol as in the kernel:



0x167e7f9d __get_user_1 vmlinux EXPORT_SYMBOL


My goal is to be able to put the put_user code in my source so I can learn how exactly the kernel can interact with userspace, but I am not having much success.



Aucun commentaire:

Enregistrer un commentaire