How to print the userspace stack trace in linux kernelspace

后端 未结 2 1662
庸人自扰
庸人自扰 2021-01-07 06:11

Say, I hook in a sys_* (e.g. sys_open) handler; when I find the argument passed from the userspace is malicious, I print the stack trace of the userspace. How can I do it? <

2条回答
  •  别那么骄傲
    2021-01-07 06:54

    You can send a signal(e.g. SIGBUS, SIGKABRT), which can generate a core dump file, to the target process in kernel.

    For example:

     do_send_sig_info(SIGABRT, SEND_SIG_FORCED, current, true);
    

    Then you can use gdb to show the backtrace of generated core file.

    It's very tricky with limited scope of application.

提交回复
热议问题