在kext

时间:2016-02-25 18:14:39

标签: c macos kernel darwin kernel-extension

我内心恐慌,无法弄清楚原因。

可能会导致以下函数在OS X 10.11.3中的内核扩展中崩溃,导致恐慌?

static int parent_pid(int pid) {
    int ppid = 0;
    proc_t process = proc_find(pid);
    if (process) {
        ppid = proc_ppid(process);
        proc_rele(process);
    }
    return ppid;
}

恐慌发生在proc_rele()内,因为它依次称为_lck_mtx_lock。据我所知,proc_rele()在这里绝对正确使用。整个kext中没有其他来电proc_find()proc_self(),因此原因不应该是代码中其他地方缺少proc_rele()

我有没有考虑某种竞争条件或线程问题?我是否需要使用锁定来保护对proc_find() / proc_rele()的来电?

0 个答案:

没有答案