简体   繁体   中英

Killing a userspace program from a kernel module

我只是想知道是否有一种方法可以从内核模块中杀死用户空间程序。我知道kill命令是行不通的,因为它是从用户空间到内核空间的系统调用。

This code will kill the calling process...

int signum = SIGKILL;
task = current;
struct siginfo info;
memset(&info, 0, sizeof(struct siginfo));
info.si_signo = signum;
int ret = send_sig_info(signum, &info, task);
if (ret < 0) {
  printk(KERN_INFO "error sending signal\n");
}

You can see how the OOM killer does it here...

http://lxr.free-electrons.com/source/mm/oom_kill.c?v=3.16#L516

If you know what syscall can be used by userspace to deliver signals, why can't you check how it is implemented? More importantly though, why do you think you need to send a signal in the first place? How do you determine what to signal in the first place?

Is this another beyond terrible college assignment?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM