linux __user 宏的含义是什么? [英] What are the implications of the linux __user macro?

查看:25
本文介绍了linux __user 宏的含义是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有人能解释 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 代码 (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.

感谢您的关注!

推荐答案

它允许像 sparse 告诉内核开发人员他们可能不正确地使用不受信任的指针(或在当前虚拟地址映射中可能无效的指针).

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆