我无法找到适合我在内核和用户空间中生成一致HMACS的问题的文档。根据LKD的R.Love,内存描述符mm-> start_code和mm-> end_code应该包含.text段。在静态可执行文件中查找.text段在ELF文档中有很好的定义,很容易找到。因此,考虑到以下两个代码片段,一个期望得到匹配HMAC:什么时候ELF .text段不是ELF .text段?
内核:
__mm = get_task_mm(__task);
__retcode = ntru_crypto_hmac_init(__crypto_context);
if(__retcode != NTRU_CRYPTO_HMAC_OK)
return 1;
__retcode = ntru_crypto_hmac_update(__crypto_context, (const uint8_t*)__mm->start_code,
__mm->end_code - __mm->start_code);
if(__retcode != NTRU_CRYPTO_HMAC_OK)
return 1;
__retcode = ntru_crypto_hmac_final(__crypto_context, __hmac);
if(__retcode != NTRU_CRYPTO_HMAC_OK)
return 1;
return 0;
用户级:
for (j = 0; j < file_hdr32.e_shnum; j++)
{
if (!strcmp(".text", strIndex + section_hdr32[j]->sh_name))
{
retcode = ntru_crypto_hmac_init(__crypto_context());
if(retcode != NTRU_CRYPTO_HMAC_OK)
{
syslog(LOG_ERR, "ntru_crypto_hmac_init error: retcode = %d, TID(0x%lx)",
retcode,pthread_self());
return 0;
}
retcode = ntru_crypto_hmac_update(__crypto_context(),
filebuf + section_hdr32[j]->sh_offset, section_hdr32[j]->sh_size);
if(retcode != NTRU_CRYPTO_HMAC_OK)
{
syslog(LOG_ERR, "Internal crypto error (%d)", retcode);
return 0;
}
retcode = ntru_crypto_hmac_final(__crypto_context(), _hmac);
if(retcode != NTRU_CRYPTO_HMAC_OK)
{
syslog(LOG_ERR, "Failed to finalize HMAC, TID(0x%lx)", pthread_self());
return 0;
}
return 1;
}
}
在这两种情况下的.text段也正是其记录的是,但他们从来没有匹配。我已经为系统上的所有17,000个可执行文件生成了用户级HMACS,所以即使内核内存描述符中的代码段指向依赖项,而不是主要可执行文件,我仍然应该得到一个匹配项,但没有骰子。这两个“.text”段有些根本不同,我想知道有没有人知道它是什么,这样我可以节省一些时间 - 任何线索?在此先感谢,皮特; 1
它的工作原理!万分感谢指针! – pjenney58