在kernel
代码中,有时会看到函数声明中有的参数带有__user
修饰符:
ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
LDD
给出的解释:
This annotation is a form of documentation, noting that a pointer is a user-space address that cannot be directly dereferenced. For normal compilation, __user has no effect, but it can be used by external checking software to find misuse of user-space addresses.
__user
表明参数是一个用户空间的指针,不能在kernel
代码中直接访问。也方便其它工具对代码进行检查。