I have an IOCTL handling code in kernel space (Linux kernel version 3.10). In this code, I want to separate out the IOCTLs that have come from userspace from those which have come from kernel space. How can I achieve this? Thanks.
Asked
Active
Viewed 243 times
0
-
XY problem? Why do that? – n. m. could be an AI Nov 16 '15 at 09:56
-
`IOCTLs ... which have come from kernel space` - you rarely face with them. IOCTLs are mainly intended for *use-space requests*. If some driver cares about requests from other drivers, it exports function, which performs that request without using of `ioctl()` call. – Tsyvarev Nov 16 '15 at 10:09
-
I agree. But in my case I want to avoid exporting any symbol and instead provide an ioctl interface to other kernel modules. – zeroByte Nov 16 '15 at 10:45
-
Distiguishing between user caller and kernel one is not natural for Linux kernel. You may examine stack trace, for example. But actually this seems as XY problem, as noted by @n.m. : **Why** you need that separating? If you want only *trusted* user to be allowed to this such ioctls, just check user capabilities. You may assume `root` as user which can be trusted whenever it uses ioctl from kernel modules or from user space. – Tsyvarev Nov 25 '15 at 11:56