Hey,
I was pondering about performing file operations from inside the kernel. Say we talk about a driver that is compiled within the kernel or an LKM which is loadable - it is possible to perform file operations such as open, read and write from inside the kernel using the provided sys_* functions such as sys_open and the rest. My question is, how is it possible to specify to the open syscall upon which user permissions to use? If you investigate the sys_open function you'll see that at some point (allocation) it uses the current pointer to grab the uid and gid upon which to check for permissions. How is this a problem? Well if the sys_open is called from a user process then that's normal because the user process has been interrupted and THAT process will be what the current pointer address to, but if we're doing it all in kernel then the current point will be of some random process which we have no affiliation with... So, what do you think? is it possible to explicitly provide a task_struct of a dummy process which I created on my own to functions like sys_open? Regards, Liran.
