Reputation: 565
Can a Linux Kernel Module read safely a user space command (i.e. user buffer)?
I know kernel and user space are different: user memory can not be executed from kernel space and vice-versa.
I wrote some simple LKM where commands coming from user space where simple: there, you can just copy the user buffer (command) to a kernel buffer using copy_from_user
.
Now I have a more complex LKM, and, I wonder if I can parse the user buffer (i.e. just reading it - not executing it), check if the command is valid, and then only copy the user buffer (command) to a kernel buffer using copy_from_user
(once you know the command is valid).
Is it OK to read user buffer from kernel space?
Upvotes: 1
Views: 37