在Linux内核源代码中的futex_wake_op function of futex.c中,我试图了解当在上述函数中,futex_atomic_op_inuser返回-EFAULT时,控件是如何到达这 point.This的,但是uaddr2是可写的。
但是从来源 of futex_atomic_op_inuser中,我看到它只在if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))上返回-EFAULT。
futex_atomic_op_inuser反过来调用一个__futex_atomic_op宏,在其中我在代码中看到一个-EFAULT,但是我被告知,到EFAULT的路径不需要调用__futex_atomic_op
那么,控件如何到达上述点(即if (!fshared)goto retry_private;)?
提前感谢!
发布于 2012-10-19 18:23:42
access_ok只用于检查地址范围对于给定的访问是否有效,即使是这样,它也不能总是给出一个明确的答案。见原文中的评论:
* Returns true (nonzero) if the memory block may be valid, false (zero)
* if it is definitely invalid.
*
* Note that, depending on architecture, this function probably just
* checks that the pointer is in the user space range - after calling
* this function, memory access functions may still return -EFAULT.接下来,即使该块是有效的,它也可能不存在于内存中(交换掉)。futex_atomic_op_inuser调用pagefault_disable,这将禁用正常的交换过程,因此您将得到一个硬错误,从__futex_atomic_op返回-EFAULT。
总之,所有这一切意味着,在下列情况下将达到所涉问题:
access_ok中滑过签入,或https://stackoverflow.com/questions/7434995
复制相似问题