示例#1
0
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;
}
int send_signal(int myPid) {
	/* send the signal */
	struct siginfo info;
	int ret;
	struct task_struct *t;
	struct pid *pid_struct;
	pid_t pid;
	memset(&info, 0, sizeof(struct siginfo));
	info.si_signo = SIG_TEST;
	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. 
	info.si_int = 1;  		//real time signals may have 32 bits of data.

	rcu_read_lock();

	pid = myPid; //integer value of pid
	pid_struct = find_get_pid(pid); //function to find the pid_struct
	t = pid_task(pid_struct,PIDTYPE_PID); //find the task_struct
	if(t == NULL){
		printk("no such pid\n");
		rcu_read_unlock();
		return -ENODEV;
	}
	rcu_read_unlock();
	ret = send_sig_info(SIG_TEST, &info, t);    //send the signal
	if (ret < 0) {
		printk("error sending signal\n");
		return ret;
	}
	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 int handle_get_pid_cap(struct rpc_desc *desc, void *_msg, size_t size)
{
	struct pid *pid;
	kernel_krg_cap_t cap;
	const struct cred *old_cred;
	int ret;

	pid = krg_handle_remote_syscall_begin(desc, _msg, size,
					      NULL, &old_cred);
	if (IS_ERR(pid)) {
		ret = PTR_ERR(pid);
		goto out;
	}

	ret = krg_get_cap(pid_task(pid, PIDTYPE_PID), &cap);
	if (ret)
		goto out_end;

	ret = rpc_pack_type(desc, cap);
	if (ret)
		goto err_cancel;

out_end:
	krg_handle_remote_syscall_end(pid, old_cred);

out:
	return ret;

err_cancel:
	rpc_cancel(desc);
	goto out_end;
}
示例#5
0
文件: mc.c 项目: xnvst/dev_ker_drv
void send_signal(unsigned long arg){	
	int ret;
	struct siginfo info;
	struct task_struct *t;
	/* send the signal */
	memset(&info, 0, sizeof(struct siginfo));
	info.si_signo = SIG_TEST;
	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. 
	info.si_int = arg;  		//real time signals may have 32 bits of data.

	rcu_read_lock();
//	t = find_task_by_pid_type(PIDTYPE_PID, pid);  //find the task_struct associated with this pid
	t = pid_task(find_pid_ns(user_process_pid, &init_pid_ns), PIDTYPE_PID);	
	if(t == NULL){
		printk(KERN_WARNING "no such pid\n");
		rcu_read_unlock();
		return -ENODEV;
	}
	rcu_read_unlock();
	ret = send_sig_info(SIG_TEST, &info, t);    //send the signal
	if (ret < 0) {
		printk("error sending signal\n");
		return ret;
	}
	return ret;
}
示例#6
0
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");
	}


}
示例#7
0
文件: intr2.c 项目: yonglisss/linux
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;
}
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;
	}
}
示例#9
0
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 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);
}
示例#11
0
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;
}
示例#12
0
int posix_timer_event(struct k_itimer *timr, int si_private)
{
	struct task_struct *task;
	int shared, ret = -1;
	/*
	 * FIXME: if ->sigq is queued we can race with
	 * dequeue_signal()->do_schedule_next_timer().
	 *
	 * If dequeue_signal() sees the "right" value of
	 * si_sys_private it calls do_schedule_next_timer().
	 * We re-queue ->sigq and drop ->it_lock().
	 * do_schedule_next_timer() locks the timer
	 * and re-schedules it while ->sigq is pending.
	 * Not really bad, but not that we want.
	 */
	timr->sigq->info.si_sys_private = si_private;

	rcu_read_lock();
	task = pid_task(timr->it_pid, PIDTYPE_PID);
	if (task) {
		shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
		ret = send_sigqueue(timr->sigq, task, shared);
	}
	rcu_read_unlock();
	/* If we failed to send the signal the timer stops. */
	return ret > 0;
}
示例#13
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;

}
示例#14
0
文件: sys.c 项目: maraz/linux-2.6
asmlinkage long sys_setsid(void)
{
	struct task_struct *group_leader = current->group_leader;
	struct pid *sid = task_pid(group_leader);
	pid_t session = pid_vnr(sid);
	int err = -EPERM;

	write_lock_irq(&tasklist_lock);
	/* Fail if I am already a session leader */
	if (group_leader->signal->leader)
		goto out;

	/* Fail if a process group id already exists that equals the
	 * proposed session id.
	 */
	if (pid_task(sid, PIDTYPE_PGID))
		goto out;

	group_leader->signal->leader = 1;
	__set_special_pids(sid);

	spin_lock(&group_leader->sighand->siglock);
	group_leader->signal->tty = NULL;
	spin_unlock(&group_leader->sighand->siglock);

	err = session;
out:
	write_unlock_irq(&tasklist_lock);
	return err;
}
示例#15
0
/*****************************************************************************
 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;
}
示例#16
0
/*****************************************************************************
 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;
}
//Ä£¿éŒÓÔغ¯Êý¶šÒå
static int __init wait_for_completion_interruptible_init(void)
{	
	int result;
	long leavetime;
	wait_queue_t data;
	printk("<0>into wait_for_completion_interruptible_init.\n");				
	result=kernel_thread(my_function,NULL,CLONE_KERNEL);   //ŽŽœšÐÂœø³Ì

       /*»ñÈ¡ÐÂœø³ÌµÄÃèÊö·ûÐÅÏ¢*/
	struct pid * kpid=find_get_pid(result);
	struct task_struct * task=pid_task(kpid,PIDTYPE_PID);
	init_completion(&comple);	  //³õÊŒ»¯completion±äÁ¿
	init_waitqueue_entry(&data,task);    //ÓÃÐÂœø³Ì³õÊŒ»¯µÈŽý¶ÓÁÐÔªËØ
	__add_wait_queue_tail(&(comple.wait),&data);    //œ«ÐÂœø³ÌŒÓÈëµÈŽý¶ÓÁеÄβ²¿
	leavetime=wait_for_completion_interruptible(&comple);   //×èÈûœø³Ì£¬µÈŽýÐÂœø³ÌµÄœáÊø

	/*ÏÔÊŸº¯Êýwait_for_completion_interruptible( )µÄ·µ»Øœá¹û*/
	printk("<0>the result of the wait_for_completion_interruptible is:%ld\n",leavetime);  

 	/*ÏÔÊŸº¯Êýkernel_thread( )µÄ·µ»Øœá¹û*/		
	printk("<0>the result of the kernel_thread is :%d\n",result);
	printk("<0>the current pid is:%d\n",current->pid);  //ÏÔÊŸµ±Ç°œø³ÌµÄPIDÖµ
	printk("<0>out wait_for_completion_interruptible_init.\n");
	return 0;
}
static ssize_t write_pid(struct file *file,const char __user *buf,size_t count,loff_t *ppos){
    //Send signal to user Space
    char mybuf[10];
    
    int ret = 0;
    int pid = 0;
    struct siginfo info;
    struct task_struct *t;
    copy_from_user(mybuf,buf,count);
    sscanf(mybuf,"%d",&pid);
    printk("pid = %d\n",pid);

    memset(&info,0,sizeof(struct siginfo));
    info.si_signo = SIG_TEST;
    info.si_code = SI_QUEUE;
    info.si_int = 1234;

    rcu_read_lock();
    //t = find_task_by_pid_type(PIDTYPE_PID, pid);  //find the task_struct associated with this pid
    t = pid_task(find_pid_ns(pid, &init_pid_ns), PIDTYPE_PID);
    if(t == NULL){
        printk(KERN_INFO "no such pid\n");
        rcu_read_unlock();
        return -ENODEV;
    }
    rcu_read_unlock();

    ret = send_sig_info(SIG_TEST,&info, t);

    if(ret<0){
        printk(KERN_INFO "send signal error");
    }
    return count;
}
示例#19
0
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;
}
示例#20
0
/*Ä£¿éŒÓÔغ¯Êý¶šÒå*/
static int __init init_waitqueue_entry_init(void)
{	
	//ŸÖ²¿±äÁ¿¶šÒå
	int result;	
	wait_queue_t data;	

	printk("<0>into init_waitqueue_entry_init.\n");
	
	/*ŽŽœš1žöÐÂœø³Ì*/				
	result=kernel_thread(my_function,NULL,CLONE_KERNEL);

	/*»ñÈ¡ÐÂœø³ÌµÄœø³ÌÃèÊö·ûÐÅÏ¢*/
	struct pid * kpid = find_get_pid(result);
	struct task_struct * task = pid_task(kpid,PIDTYPE_PID);
	
	if(data.private==NULL||data.func==NULL)
	{
		printk("<0>the data has not been initialized\n");	
	}	

	 /*ÓÃÐÂœø³Ì³õÊŒ»¯µÈŽý¶ÓÁÐÔªËØ*/
	init_waitqueue_entry(&data,task);
	if(data.private==task && data.func!=NULL)
	{
		printk("<0>the data has been initialized\n");
		printk("<0>the flags of the data is:%d\n",data.flags);
	}	
	else
	{
示例#21
0
// 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);
}
示例#22
0
文件: exmap.c 项目: jbert/exmap
static struct task_struct *my_find_task_by_pid(pid_t pid) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
    return pid_task(find_pid_ns(pid, &init_pid_ns), PIDTYPE_PID);
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
    /* The pid has come from userspace, so we can use f_t_b_vpid to look up */
    return find_task_by_vpid(pid);
#else
    return find_task_by_pid(pid);
#endif
}
static inline struct task_struct* rasmemele_task(struct RasMemEle* ele)
{
	struct pid_namespace *ns = current->nsproxy->pid_ns;
	struct pid* pd = find_pid_ns(ele->args.pid, ns);
	struct task_struct* tsk; 
	rcu_read_lock();
	tsk = pid_task(pd, PIDTYPE_PID);
	rcu_read_unlock();
	return tsk;
}
/**
 * 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;
}
示例#25
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;
}
示例#26
0
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 ;      
}
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
				}
			}
		}
	}
示例#28
0
// 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);
}
示例#29
0
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;
}
示例#30
0
void debug_rt_mutex_print_deadlock(struct rt_mutex_waiter *waiter)
{
	struct task_struct *task;

	if (!waiter->deadlock_lock || !debug_locks)
		return;

	rcu_read_lock();
	task = pid_task(waiter->deadlock_task_pid, PIDTYPE_PID);
	if (!task) {
		rcu_read_unlock();
		return;
	}

	if (!debug_locks_off()) {
		rcu_read_unlock();
		return;
	}

	pr_warn("\n");
	pr_warn("============================================\n");
	pr_warn("WARNING: circular locking deadlock detected!\n");
	pr_warn("%s\n", print_tainted());
	pr_warn("--------------------------------------------\n");
	printk("%s/%d is deadlocking current task %s/%d\n\n",
	       task->comm, task_pid_nr(task),
	       current->comm, task_pid_nr(current));

	printk("\n1) %s/%d is trying to acquire this lock:\n",
	       current->comm, task_pid_nr(current));
	printk_lock(waiter->lock, 1);

	printk("\n2) %s/%d is blocked on this lock:\n",
		task->comm, task_pid_nr(task));
	printk_lock(waiter->deadlock_lock, 1);

	debug_show_held_locks(current);
	debug_show_held_locks(task);

	printk("\n%s/%d's [blocked] stackdump:\n\n",
		task->comm, task_pid_nr(task));
	show_stack(task, NULL);
	printk("\n%s/%d's [current] stackdump:\n\n",
		current->comm, task_pid_nr(current));
	dump_stack();
	debug_show_all_locks();
	rcu_read_unlock();

	printk("[ turning off deadlock detection."
	       "Please report this trace. ]\n\n");
}