int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid, const time_t shm_createtime) { #ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT struct pid *pid = NULL; time_t starttime; if (unlikely(!grsec_enable_chroot_shmat)) return 1; if (likely(!proc_is_chrooted(current))) return 1; read_lock(&tasklist_lock); pid = find_vpid(shm_cprid); if (pid) { struct task_struct *p; p = pid_task(pid, PIDTYPE_PID); task_lock(p); starttime = p->start_time.tv_sec; if (unlikely(!have_same_root(current, p) && time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime))) { task_unlock(p); read_unlock(&tasklist_lock); gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG); return 0; } task_unlock(p); } else { pid = find_vpid(shm_lapid); if (pid) { struct task_struct *p; p = pid_task(pid, PIDTYPE_PID); task_lock(p); if (unlikely(!have_same_root(current, p))) { task_unlock(p); read_unlock(&tasklist_lock); gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG); return 0; } task_unlock(p); } } read_unlock(&tasklist_lock); #endif return 1; }
SYSCALL_DEFINE2(smunch, pid_t,pid, long, bit_pattern){ //Check if multi threaded struct task_struct *p; bool ret; p = pid_task(find_vpid(pid), PIDTYPE_PID); if(!p){ pr_alert("\nprocess table is null"); return -1; } ret = current_is_single_threaded(); if(ret == false){ pr_alert("\nError : Multithreaded process, cannot proceed\n"); return -1; } //Check if traced if(p->ptrace & PT_PTRACED){ pr_alert("\nError : Traced process, cannot proceed\n"); return -1; } //Check if zombie state if(p->exit_state == EXIT_ZOMBIE){ if((1 << (SIGKILL-1)) & bit_pattern){ release_task(p); } return 0; } else{ p->pending.signal.sig[0] |= bit_pattern; wake_up_process(p); } return 0; }
static void print_thread_info(int pid) { struct task_struct *ptask; struct pid *k; struct thread_info *threadinfo = NULL; union thread_union *threadunion = NULL; /* find tak by pid */ k = find_vpid(pid); ptask = pid_task(k, PIDTYPE_PID); printk(KERN_INFO "process : %s, pid : %d\n", ptask->comm, ptask->pid); /* ptask->stack point to thread_unuion */ threadinfo = get_thread_info(ptask); /* union thread_union * { * struct thread_info thread_info; * unsigned long stack[THREAD_SIZE/sizeof(long)]; * }; */ threadunion = get_thread_union(threadinfo); show_kstack(threadunion); //printk(KERN_INFO "task stack : %p\n", ptask->stack); }
static void notify_user(struct job *job, int err, int cid) { struct siginfo sinfo; struct task_struct *task; memset(&sinfo, 0, sizeof(struct siginfo)); sinfo.si_code = SI_QUEUE; /* important, make si_int available */ sinfo.si_int = job->id; sinfo.si_signo = SIGUSR1; sinfo.si_uid = current_uid(); if (job->state == STATE_SUCCESS) sinfo.si_errno = 0; else if (job->state == STATE_FAILED) sinfo.si_errno = -err; /* make it positive */ else return; task = pid_task(find_vpid(job->pid), PIDTYPE_PID); if (!task) { INFO("Consumer/%d: pid[%d] not found", cid, job->pid); return; } send_sig_info(SIGUSR1, &sinfo, task); }
static irqreturn_t intr_handler(int irq,void * dev_id) { pid_t pid; struct task_struct *p; static long interval = 0; if(count==0){ interval=jiffies; } //count the interval between two irqs interval=jiffies-interval; printk("The interval between two interrupts is %ld\n",interval); interval=jiffies; //printk("Interrupt on %s —–%d /n",dev->name,dev->irq); count++; //pid = sys_getpid(); asm( "movl $0x20,%%eax\n\t" "int $0x80\n\t" :"=a"(pid) ); p = pid_task(find_vpid(pid),PIDTYPE_PID); printk("进程%d的状态:state=%ld prio=%d policy=%d\n",pid,p->state,p->prio,p->policy); return IRQ_NONE; }
void ged_dvfs_probe_signal(int signo) { static int cache_pid=GED_NO_UM_SERVICE; static struct task_struct *t=NULL; struct siginfo info; info.si_signo = signo; info.si_code = SI_QUEUE; info.si_int = 1234; if(cache_pid!=g_probe_pid) { cache_pid = g_probe_pid; if(g_probe_pid==GED_NO_UM_SERVICE) t = NULL; else t = pid_task(find_vpid(g_probe_pid), PIDTYPE_PID); } if(t!=NULL) { send_sig_info(signo, &info, t); ged_log_buf_print(ghLogBuf_ged_srv, "[GED_K] send signo %d to ged_srv [%d]",signo, g_probe_pid); } else { g_probe_pid = GED_NO_UM_SERVICE; ged_log_buf_print(ghLogBuf_ged_srv, "[GED_K] ged_srv not running"); } }
static void check_ma(struct quadd_hrt_ctx *hrt_ctx) { pid_t pid; struct pid *pid_s; struct task_struct *task = NULL; struct mm_struct *mm; struct quadd_ctx *quadd_ctx = hrt_ctx->quadd_ctx; unsigned long vm_size, rss_size; pid = quadd_ctx->param.pids[0]; rcu_read_lock(); pid_s = find_vpid(pid); if (pid_s) task = pid_task(pid_s, PIDTYPE_PID); rcu_read_unlock(); if (!task) return; mm = task->mm; if (!mm) return; vm_size = mm->total_vm; rss_size = get_mm_rss(mm); if (vm_size != hrt_ctx->vm_size_prev || rss_size != hrt_ctx->rss_size_prev) { make_sample(hrt_ctx, pid, vm_size, rss_size); hrt_ctx->vm_size_prev = vm_size; hrt_ctx->rss_size_prev = rss_size; } }
static int _mtk_cl_sd_send_signal(void) { int ret = 0; if (tm_input_pid == 0) { mtk_cooler_shutdown_dprintk("%s pid is empty\n", __func__); ret = -1; } mtk_cooler_shutdown_dprintk("%s pid is %d, %d\n", __func__, tm_pid, tm_input_pid); if (ret == 0 && tm_input_pid != tm_pid) { tm_pid = tm_input_pid; pg_task = get_pid_task(find_vpid(tm_pid), PIDTYPE_PID); } if (ret == 0 && pg_task) { siginfo_t info; info.si_signo = SIGIO; info.si_errno = 0; info.si_code = 1; info.si_addr = NULL; ret = send_sig_info(SIGIO, &info, pg_task); } if (ret != 0) mtk_cooler_shutdown_dprintk("%s ret=%d\n", __func__, ret); return ret; }
int gr_handle_chroot_unix(const pid_t pid) { #ifdef CONFIG_GRKERNSEC_CHROOT_UNIX struct pid *spid = NULL; if (unlikely(!grsec_enable_chroot_unix)) return 1; if (likely(!proc_is_chrooted(current))) return 1; read_lock(&tasklist_lock); spid = find_vpid(pid); if (spid) { struct task_struct *p; p = pid_task(spid, PIDTYPE_PID); task_lock(p); if (unlikely(!have_same_root(current, p))) { task_unlock(p); read_unlock(&tasklist_lock); gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG); return 0; } task_unlock(p); } read_unlock(&tasklist_lock); #endif return 1; }
//when write somethinf in a file static ssize_t jiffies_proc_write(struct file *filp, const char __user *buff, size_t len, loff_t *data) { long res; printk(KERN_INFO "JIFFIES: Write has been called"); if (len > (JIFFIES_BUFFER_LEN - 1)) { printk(KERN_INFO "JIFFIES: error, input too long"); return -EINVAL; } else if (copy_from_user(jiffies_buffer, buff, len)) { return -2; } jiffies_buffer[len] = 0; kstrtol(jiffies_buffer, 0, &res); //jiffies_flag content the echo jiffies_flag = res; //task = pid_task(find_vpid(jiffies_flag, PIDTYPE_PID)) if(task) //if the pid exist if(find_vpid(jiffies_flag)!=NULL) { //copy the content of jiffies_flag in jiffies_buffer snprintf(jiffies_buffer, 10, "%d", jiffies_flag); //create a file in proc/ase with the pid give in jiffies_buffer proc_create(jiffies_buffer, 0666, ase, &jiffies_proc_fops); pid_list[cptpid] = jiffies_flag; cptpid++; } else{ printk(KERN_INFO "JIFFIES: error, this pid doesn't exist"); } return len; }
static long procinfo_ioctl(struct file *f, unsigned int cmd, unsigned long arg) #endif { procinfo_t info; procinfo_arg_t *info_arg; struct task_struct *task; pid_t pid; switch (cmd) { case GET_PROCINFO: info_arg = (procinfo_arg_t *) arg; pid = info_arg->pid; if (pid > 0) { task = pid_task(find_vpid(pid), PIDTYPE_PID); } else if (pid == 0) { task = current; } else if (pid < 0) { task = current->parent; } if (task == NULL) { return -EINVAL; } info.pid = task->pid; info.ppid = task->parent->pid; info.start_time = task->start_time; info.num_sib = count_list(&task->sibling); if (copy_to_user(info_arg->info, &info, sizeof(procinfo_t))) { return -EACCES; } break; default: return -EINVAL; } return 0; }
int Moca_InitProcessManagment(int id) { // Monitored pids struct pid *pid; if(!(Moca_tasksMap=Moca_InitHashMap(Moca_tasksHashBits, 2*(1<<Moca_tasksHashBits), sizeof(struct _moca_task), NULL, Moca_TaskInitializer))) goto fail; rcu_read_lock(); pid=find_vpid(id); if(!pid) { // Skip internal process rcu_read_unlock(); goto clean; } Moca_initTask=pid_task(pid, PIDTYPE_PID); rcu_read_unlock(); if(Moca_InitTaskData()!=0) goto clean; return 0; clean: Moca_FreeMap(Moca_tasksMap); fail: printk(KERN_NOTICE "Moca fail initializing process data \n"); return 1; }
int f_setown(struct file *filp, unsigned long arg, int force) { enum pid_type type; struct pid *pid = NULL; int who = arg, ret = 0; type = PIDTYPE_PID; if (who < 0) { /* avoid overflow below */ if (who == INT_MIN) return -EINVAL; type = PIDTYPE_PGID; who = -who; } rcu_read_lock(); if (who) { pid = find_vpid(who); if (!pid) ret = -ESRCH; } if (!ret) __f_setown(filp, pid, type, force); rcu_read_unlock(); return ret; }
static int wmt_send_signal(int level) { int ret = 0; int thro = level; if (tm_input_pid == 0) { mtk_cooler_amdtxctrl_dprintk("[%s] pid is empty\n", __func__); ret = -1; } mtk_cooler_amdtxctrl_dprintk_always("[%s] pid is %d, %d, %d\n", __func__, tm_pid, tm_input_pid, thro); if (ret == 0 && tm_input_pid != tm_pid) { tm_pid = tm_input_pid; pg_task = get_pid_task(find_vpid(tm_pid), PIDTYPE_PID); } if (ret == 0 && pg_task) { siginfo_t info; info.si_signo = SIGIO; info.si_errno = 1; // for md ul throttling info.si_code = thro; info.si_addr = NULL; ret = send_sig_info(SIGIO, &info, pg_task); } if (ret != 0) mtk_cooler_amdtxctrl_dprintk("[%s] ret=%d\n", __func__, ret); return ret; }
/***************************************************************************** Function : VOS_ResumeTask Description: Resume a task Input : ulTaskID -- ID of task Return : Return VOS_OK if successd *****************************************************************************/ VOS_UINT32 VOS_ResumeTask( VOS_UINT32 ulTaskID ) { pid_t ulTemp; struct task_struct *tsk; if(ulTaskID >= vos_TaskCtrlBlkNumber) { return(VOS_ERR); } ulTemp = vos_TaskCtrlBlk[ulTaskID].ulLinuxThreadId; tsk = pid_task(find_vpid(ulTemp), PIDTYPE_PID); if ( VOS_NULL_PTR == tsk) { return(VOS_ERR); } if ( tsk->pid != ulTemp ) { printk("resume find task to set pri fail.\r\n"); return VOS_ERR; } /*set_task_state(tsk, TASK_RUNNING);*/ wake_up_process(tsk); return VOS_OK; }
/***************************************************************************** Function : VOS_SuspendTask Description: Suspend a task Calls : OSAL_SuspendTask Called By : Input : ulTaskID -- id of a task Output : none Return : return VOS_OK if success Other : none *****************************************************************************/ VOS_UINT32 VOS_SuspendTask( VOS_UINT32 ulTaskID ) { struct task_struct *tsk; pid_t ulTemp; if( ulTaskID >= vos_TaskCtrlBlkNumber ) { return(VOS_ERR); } ulTemp = vos_TaskCtrlBlk[ulTaskID].ulLinuxThreadId; tsk = pid_task(find_vpid(ulTemp), PIDTYPE_PID); if ( VOS_NULL_PTR == tsk) { return(VOS_ERR); } if ( tsk->pid != ulTemp ) { printk("susupend find task to set pri fail.\r\n"); return VOS_ERR; } set_task_state(tsk, TASK_UNINTERRUPTIBLE); if (tsk == current) { schedule(); } return VOS_OK; }
static int vloopback_open(struct file *f) #endif { struct video_device *loopdev = video_devdata(f); #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32) priv_ptr ptr = (priv_ptr)dev_get_drvdata(&loopdev->dev); #else priv_ptr ptr = (priv_ptr)loopdev->vd_private_data; #endif int nr = ptr->pipenr; if (debug > LOG_NODEBUG) info("Video loopback %d", nr); /* Only allow a output to be opened if there is someone feeding * the pipe. */ if (!ptr->in) { if (loops[nr]->buffer == NULL) return -EINVAL; loops[nr]->framesread = 0; loops[nr]->ropen = 1; } else { if (loops[nr]->ropen || loops[nr]->wopen) return -EBUSY; loops[nr]->framesdumped = 0; loops[nr]->frameswrite = 0; loops[nr]->wopen = 1; loops[nr]->zerocopy = 0; loops[nr]->ioctlnr = -1; pipesused++; if (nr_o_pipes-pipesused<spares) { if (!create_pipe(nr_o_pipes)) { info("Creating extra spare pipe"); info("Loopback %d registered, input: video%d, output: video%d", nr_o_pipes, loops[nr_o_pipes]->vloopin->minor, loops[nr_o_pipes]->vloopout->minor ); nr_o_pipes++; } } #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) loops[nr]->pid = current->pid; #elif LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30) loops[nr]->pid = find_vpid(current->pid); #else // TODO : Check in stable 2.6.27 loops[nr]->pid = task_pid(find_task_by_vpid(current->pid)); //loops[nr]->pid = task_pid(current); #endif if (debug > LOG_NODEBUG) info("Current pid %d", current->pid); } return 0; }
static long eventfd_link_ioctl_copy2(unsigned long arg) { void __user *argp = (void __user *) arg; struct task_struct *task_target = NULL; struct file *file; struct files_struct *files; struct eventfd_copy2 eventfd_copy2; long ret = -EFAULT; if (copy_from_user(&eventfd_copy2, argp, sizeof(struct eventfd_copy2))) goto out; /* * Find the task struct for the target pid */ ret = -ESRCH; task_target = get_pid_task(find_vpid(eventfd_copy2.pid), PIDTYPE_PID); if (task_target == NULL) { pr_info("Unable to find pid %d\n", eventfd_copy2.pid); goto out; } ret = -ESTALE; files = get_files_struct(task_target); if (files == NULL) { pr_info("Failed to get target files struct\n"); goto out_task; } ret = -EBADF; file = fget_from_files(files, eventfd_copy2.fd); put_files_struct(files); if (file == NULL) { pr_info("Failed to get fd %d from target\n", eventfd_copy2.fd); goto out_task; } /* * Install the file struct from the target process into the * newly allocated file desciptor of the source process. */ ret = get_unused_fd_flags(eventfd_copy2.flags); if (ret < 0) { fput(file); goto out_task; } fd_install(ret, file); out_task: put_task_struct(task_target); out: return ret; }
// Return count of each signal under a process SYSCALL_DEFINE1(get_sigcounter, int, signumber){ unsigned long flags; struct task_struct *p; pid_t pid = current->pid; p = pid_task(find_vpid(pid), PIDTYPE_PID); lock_task_sighand(p, &flags); pr_alert("%d\n", p->sighand->sigcounter[signumber]); unlock_task_sighand(p, &flags); return(1); }
/** * send message to given destination */ asmlinkage long sys_SendMsg(pid_t dest, void *a_msg, int len, bool block){ pid_t my_pid = current->pid; void* msg = new_msg(); message* this_mail; mailbox* dest_mailbox; signal* dest_signal; struct task_struct* dest_ts; int existence; if ((len > MAX_MSG_SIZE) || (len < 0)) return MSG_LENGTH_ERROR; if (copy_from_user(msg, a_msg, len)) return MSG_ARG_ERROR; //check if destination is valid if (dest <= 0) return MAILBOX_INVALID; //find task struct for destination pid dest_ts = pid_task(find_vpid(dest), PIDTYPE_PID); // find_task_by_vpid(dest); if (dest_ts == NULL) return MAILBOX_INVALID; //state not 0 or kernel task, invalid dest existence = dest_ts->state; if ((existence != 0) || (dest_ts->mm == NULL)) return MAILBOX_INVALID; //get destination mailbox dest_signal = get_signal(dest); if (dest_signal == NULL) { dest_signal = create_signal(dest, TRUE); } dest_mailbox = get_mailbox(dest); if (dest_mailbox == NULL) { dest_mailbox = create_mailbox(dest); if (dest_mailbox == NULL) return MAILBOX_ERROR; } wake_up(&(dest_signal->wait_null)); if ((block == TRUE) && (dest_mailbox->full == TRUE)){ //wait until not full and send message } else if (block == FALSE && (dest_mailbox->full == TRUE)) return MAILBOX_FULL; if (dest_mailbox->stop) return MAILBOX_STOPPED; this_mail = create_message(my_pid, len, msg); spin_lock(&(dest_mailbox->lock)); add_message(&dest_mailbox, &this_mail); spin_unlock(&(dest_mailbox->lock)); //successfully sent return 0; }
static int jiffies_proc_show(struct seq_file *m, void *v) { /*if (jiffies_flag) seq_printf(m, "%llu\n", (unsigned long long) get_jiffies_64());*/ task = pid_task(find_vpid(jiffies_flag), PIDTYPE_PID); //printk(KERN_INFO "timestamp of the task : %llu", (unsigned long long)task->utime) seq_printf(m, "%llu\n", (unsigned long long) task->utime); return 0; }
/* * Ugh. To avoid negative return values, "getpriority()" will * not return the normal nice-value, but a negated value that * has been offset by 20 (ie it returns 40..1 instead of -20..19) * to stay compatible. */ asmlinkage long sys_getpriority(int which, int who) { struct task_struct *g, *p; struct user_struct *user; long niceval, retval = -ESRCH; struct pid *pgrp; if (which > PRIO_USER || which < PRIO_PROCESS) return -EINVAL; read_lock(&tasklist_lock); switch (which) { case PRIO_PROCESS: if (who) p = find_task_by_vpid(who); else p = current; if (p) { niceval = 20 - task_nice(p); if (niceval > retval) retval = niceval; } break; case PRIO_PGRP: if (who) pgrp = find_vpid(who); else pgrp = task_pgrp(current); do_each_pid_task(pgrp, PIDTYPE_PGID, p) { niceval = 20 - task_nice(p); if (niceval > retval) retval = niceval; } while_each_pid_task(pgrp, PIDTYPE_PGID, p); break; case PRIO_USER: user = current->user; if (!who) who = current->uid; else if ((who != current->uid) && !(user = find_user(who))) goto out_unlock; /* No processes for this user */ do_each_thread(g, p) if (p->uid == who) { niceval = 20 - task_nice(p); if (niceval > retval) retval = niceval; } while_each_thread(g, p); if (who != current->uid) free_uid(user); /* for find_user() */ break; }
static void printvm_tree(void) { struct task_struct *p; struct pid *k; struct rb_node *root = NULL; k = find_vpid(pid); p = pid_task(k,PIDTYPE_PID); root = p->mm->mm_rb.rb_node; print_rb_tree(root); return ; }
// Initialize count for each signal under a process SYSCALL_DEFINE1(init_sigcounter, pid_t, pid){ unsigned long flags; int i; struct task_struct *p; p = pid_task(find_vpid(pid), PIDTYPE_PID); lock_task_sighand(p, &flags); for(i = 0; i < 64; i++){ p->sighand->sigcounter[i] = 0; } unlock_task_sighand(p, &flags); return(1); }
static irqreturn_t gpio_edge_interrupt(int irq, void* dev_id) { _gpio_handler* handler=(_gpio_handler*)dev_id; if(handler && (handler->irq == irq)) { int val=0; debug("Got _handler!\n"); val=(__raw_readl(ath79_gpio_base + AR71XX_GPIO_REG_IN) >> handler->gpio) & 1; if(val != handler->last_value) { struct siginfo info; struct task_struct* ts=NULL; int i=0; handler->last_value=val; debug("IRQ %d event (GPIO %d) - new value is %d!\n", irq, handler->gpio, val); /* send the signal */ memset(&info, 0, sizeof(struct siginfo)); info.si_signo = SIG_GPIO_IRQ; info.si_code = SI_QUEUE; // this is bit of a trickery: SI_QUEUE is normally used by sigqueue from user space, // and kernel space should use SI_KERNEL. But if SI_KERNEL is used the real_time data // is not delivered to the user space signal handler function. for(i=0; i < MAX_PROCESSES; ++i) { pid_t pid=handler->processes[i]; if(pid == 0) break; info.si_int=(handler->gpio << 24) | (val & 1); rcu_read_lock(); ts=pid_task(find_vpid(pid), PIDTYPE_PID); rcu_read_unlock(); if(ts == NULL) { debug("PID %u is not found, remove it please.\n",pid); } else { debug("Sending signal to PID %u.\n",pid); send_sig_info(SIG_GPIO_IRQ, &info, ts); //send the signal } } } }
asmlinkage long sys_setpriority(int which, int who, int niceval) { struct task_struct *g, *p; struct user_struct *user; int error = -EINVAL; struct pid *pgrp; if (which > PRIO_USER || which < PRIO_PROCESS) goto out; /* normalize: avoid signed division (rounding problems) */ error = -ESRCH; if (niceval < -20) niceval = -20; if (niceval > 19) niceval = 19; read_lock(&tasklist_lock); switch (which) { case PRIO_PROCESS: if (who) p = find_task_by_vpid(who); else p = current; if (p) error = set_one_prio(p, niceval, error); break; case PRIO_PGRP: if (who) pgrp = find_vpid(who); else pgrp = task_pgrp(current); do_each_pid_task(pgrp, PIDTYPE_PGID, p) { error = set_one_prio(p, niceval, error); } while_each_pid_task(pgrp, PIDTYPE_PGID, p); break; case PRIO_USER: user = current->user; if (!who) who = current->uid; else if ((who != current->uid) && !(user = find_user(who))) goto out_unlock; /* No processes for this user */ do_each_thread(g, p) if (p->uid == who) error = set_one_prio(p, niceval, error); while_each_thread(g, p); if (who != current->uid) free_uid(user); /* For find_user() */ break; }
static void shutdown_umh(struct umh_info *info) { struct task_struct *tsk; if (!info->pid) return; tsk = pid_task(find_vpid(info->pid), PIDTYPE_PID); if (tsk) force_sig(SIGKILL, tsk); fput(info->pipe_to_umh); fput(info->pipe_from_umh); info->pid = 0; }
static void dump_process_state(int bad_pid) { struct pid *bad_p; struct task_struct *p; bad_p = find_vpid(bad_pid); printk(KERN_ERR "###################################################\n"); printk(KERN_ERR "%s: Running on PID %d (%p)\n", __func__, bad_pid, bad_p); printk(KERN_ERR "###################################################\n"); if(!bad_p) return; do_each_pid_thread(bad_p, PIDTYPE_PID, p) { sched_show_task(p); } while_each_pid_thread(bad_p, PIDTYPE_PID, p);
int init_sigcounter(int pid){ struct task_struct *p; struct sighand_struct *sighand; int i; unsigned long flags; p = pid_task(find_vpid(pid), PIDTYPE_PID); lock_task_sighand(p, &flags); sighand = p -> sighand; for(i = 0; i < 64; ++i){ sighand -> sigcounter[i] = 0; } unlock_task_sighand(p, &flags); return 0; }
static void abort_suspicious_process(int bad_pid) { struct pid *bad_p = find_vpid(bad_pid); if (bad_p) { printk(KERN_ERR "Killing process(%d) with signal %d\n", bad_pid, SIGABRT); kill_pid(bad_p, SIGABRT, 1); } else { printk(KERN_ERR "%s: Invalid pid %d.\n", __func__, bad_pid); } }