针对同一个 filep, 会不会其他调用比如 ioctl 正在调用过程中, 另一个线程调用了 close, 从而导致在 compat_ioctl, unlocked_ioctl 什么的还没有完成, release 已经进去了?
android binder驱动里面就有这么几个情景:
在release 中
while ((n = rb_first(&proc->threads))) {
struct binder_thread *thread;
thread = rb_entry(n, struct binder_thread, rb_node);
binder_inner_proc_unlock(proc);
threads++;
active_transactions += binder_thread_release(proc, thread);
binder_inner_proc_lock(proc);
}
这过这个thread 在 binder_inner_proc_unlock 前引用计数没自增, 而是在 binder_thread_release 中有 自增->完成操作->自减, 到0 free的逻辑
另外一边:
ioctl 中有
thread = binder_get_thread(proc);
case BINDER_THREAD_EXIT:
binder_debug(BINDER_DEBUG_THREADS, "%d:%d exit\n",
proc->pid, thread->pid);
binder_thread_release(proc, thread);
thread = NULL;
break;
binder_get_thread 同样没有 +1 操作
那么. 我就有理由相信两者发生了竞争
导致一个野指针问题