什么是Linux的__user宏的含义是什么? [英] What are the implications of the linux __user macro?
问题描述
我希望有人可以解释在Linux内核源代码中使用的__user宏的细微差别。
I was hoping someone could explain the nuances of the __user macro used in the linux kernel source.
首先,宏观:
# define __user __attribute__((noderef, address_space(1)))
现在,一些谷歌搜索后,我读了这个宏允许一个指定的指针为属于用户地址空间,而且它不应该被取消引用。
Now, after some googling I read that this macro allows one to designate a pointer as belonging to the user address space, and that it should not be dereferenced.
我可能会丢失一些明显的事实,但也有人请解释这样一个宏的含义是什么?比如,什么是在哪里这个宏将使用一个很好的例子?再次,原谅我,如果我失去了一些东西明显。
I may be missing some obvious facts, but could someone please explain the implications of such a macro? For instance, what is a good example of where this macro would be of use? Again, forgive me if I am missing something obvious.
为了把这个在某些情况下,我来到翻过宏在检查一些USB code(Linux的/ usbdevice_fs.h)。我只是寻找这个宏的一般理解(或者其他类似的)在内核中使用。
To put this in some context, I came accross the macro while examining some USB code (linux/usbdevice_fs.h). I am only looking for a general understanding of this macros( or others like it) use within the kernel.
感谢您看!
推荐答案
这让像稀疏工具来告诉内核开发他们正在可能使用不受信任的指针(或可能是在当前的虚拟地址映射无效指针)不正确。
It allows tools like sparse to tell kernel developers that they're possibly using an untrusted pointer (or a pointer that may be invalid in the current virtual address mapping) improperly.
这篇关于什么是Linux的__user宏的含义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!