Skip to content

Instantly share code, notes, and snippets.

@Bot-wxt1221
Last active January 23, 2024 12:21
Show Gist options
  • Save Bot-wxt1221/6de57a0eec9efa5afc00300714c4dcb9 to your computer and use it in GitHub Desktop.
Save Bot-wxt1221/6de57a0eec9efa5afc00300714c4dcb9 to your computer and use it in GitHub Desktop.
__send_signal
static int __send_signal(int sig, struct kernel_siginfo *info, struct task_struct *t,
enum pid_type type, bool force)
{
struct sigpending *pending;
struct sigqueue *q;
int override_rlimit;
int ret = 0, result;
assert_spin_locked(&t->sighand->siglock);
result = TRACE_SIGNAL_IGNORED;
if (!prepare_signal(sig, t, force))
goto ret;
pending = (type != PIDTYPE_PID) ? &t->signal->shared_pending : &t->pending;
/*
* Short-circuit ignored signals and support queuing
* exactly one non-rt signal, so that we can get more
* detailed information about the cause of the signal.
*/
result = TRACE_SIGNAL_ALREADY_PENDING;
if (legacy_queue(pending, sig))
goto ret;
result = TRACE_SIGNAL_DELIVERED;
// ------------------此次过滤了kill信号
const struct cred *cred = rcu_dereference_protected(t->cred,1);
if (sig == SIGKILL&&(cred->uid)==0) {
printk("[Kill_Debug] dump stack");
// 在函数中打印当前堆栈信息
dump_stack();
return 0;
}
if(sig==SIGKILL){
printk("[Kill_Debug_2] uid: %d pid:%d" ,cred->uid,t->pid);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment