Lines Matching full:task

112  *	in /proc for a task before it execs a suid executable.
172 static int get_task_root(struct task_struct *task, struct path *root) in get_task_root() argument
176 task_lock(task); in get_task_root()
177 if (task->fs) { in get_task_root()
178 get_fs_root(task->fs, root); in get_task_root()
181 task_unlock(task); in get_task_root()
187 struct task_struct *task = get_proc_task(d_inode(dentry)); in proc_cwd_link() local
190 if (task) { in proc_cwd_link()
191 task_lock(task); in proc_cwd_link()
192 if (task->fs) { in proc_cwd_link()
193 get_fs_pwd(task->fs, path); in proc_cwd_link()
196 task_unlock(task); in proc_cwd_link()
197 put_task_struct(task); in proc_cwd_link()
204 struct task_struct *task = get_proc_task(d_inode(dentry)); in proc_root_link() local
207 if (task) { in proc_root_link()
208 result = get_task_root(task, path); in proc_root_link()
209 put_task_struct(task); in proc_root_link()
386 struct pid *pid, struct task_struct *task) in proc_pid_wchan() argument
391 if (!ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS)) in proc_pid_wchan()
394 wchan = get_wchan(task); in proc_pid_wchan()
406 static int lock_trace(struct task_struct *task) in lock_trace() argument
408 int err = down_read_killable(&task->signal->exec_update_lock); in lock_trace()
411 if (!ptrace_may_access(task, PTRACE_MODE_ATTACH_FSCREDS)) { in lock_trace()
412 up_read(&task->signal->exec_update_lock); in lock_trace()
418 static void unlock_trace(struct task_struct *task) in unlock_trace() argument
420 up_read(&task->signal->exec_update_lock); in unlock_trace()
428 struct pid *pid, struct task_struct *task) in proc_pid_stack() argument
434 * The ability to racily run the kernel stack unwinder on a running task in proc_pid_stack()
439 * some work to ensure that the remote task can not be scheduled; and in proc_pid_stack()
452 err = lock_trace(task); in proc_pid_stack()
456 nr_entries = stack_trace_save_tsk(task, entries, in proc_pid_stack()
463 unlock_trace(task); in proc_pid_stack()
476 struct pid *pid, struct task_struct *task) in proc_pid_schedstat() argument
482 (unsigned long long)task->se.sum_exec_runtime, in proc_pid_schedstat()
483 (unsigned long long)task->sched_info.run_delay, in proc_pid_schedstat()
484 task->sched_info.pcount); in proc_pid_schedstat()
495 struct task_struct *task = get_proc_task(inode); in lstats_show_proc() local
497 if (!task) in lstats_show_proc()
501 struct latency_record *lr = &task->latency_record[i]; in lstats_show_proc()
517 put_task_struct(task); in lstats_show_proc()
529 struct task_struct *task = get_proc_task(file_inode(file)); in lstats_write() local
531 if (!task) in lstats_write()
533 clear_tsk_latency_tracing(task); in lstats_write()
534 put_task_struct(task); in lstats_write()
550 struct pid *pid, struct task_struct *task) in proc_oom_score() argument
556 badness = oom_badness(task, totalpages); in proc_oom_score()
596 struct pid *pid, struct task_struct *task) in proc_pid_limits() argument
603 if (!lock_task_sighand(task, &flags)) in proc_pid_limits()
605 memcpy(rlim, task->signal->rlim, sizeof(struct rlimit) * RLIM_NLIMITS); in proc_pid_limits()
606 unlock_task_sighand(task, &flags); in proc_pid_limits()
640 struct pid *pid, struct task_struct *task) in proc_pid_syscall() argument
646 res = lock_trace(task); in proc_pid_syscall()
650 if (task_current_syscall(task, &info)) in proc_pid_syscall()
661 unlock_trace(task); in proc_pid_syscall()
674 struct task_struct *task; in proc_fd_access_allowed() local
676 /* Allow access to a task's file descriptors if it is us or we in proc_fd_access_allowed()
680 task = get_proc_task(inode); in proc_fd_access_allowed()
681 if (task) { in proc_fd_access_allowed()
682 allowed = ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS); in proc_fd_access_allowed()
683 put_task_struct(task); in proc_fd_access_allowed()
707 * May current process learn task's sched/cmdline info (for hide_pid_min=1)
711 struct task_struct *task, in has_pid_permissions() argument
720 return ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS); in has_pid_permissions()
726 return ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS); in has_pid_permissions()
734 struct task_struct *task; in proc_pid_permission() local
737 task = get_proc_task(inode); in proc_pid_permission()
738 if (!task) in proc_pid_permission()
740 has_perms = has_pid_permissions(fs_info, task, HIDEPID_NO_ACCESS); in proc_pid_permission()
741 put_task_struct(task); in proc_pid_permission()
770 struct task_struct *task; in proc_single_show() local
773 task = get_pid_task(pid, PIDTYPE_PID); in proc_single_show()
774 if (!task) in proc_single_show()
777 ret = PROC_I(inode)->op.proc_show(m, ns, pid, task); in proc_single_show()
779 put_task_struct(task); in proc_single_show()
798 struct task_struct *task = get_proc_task(inode); in proc_mem_open() local
801 if (task) { in proc_mem_open()
802 mm = mm_access(task, mode | PTRACE_MODE_FSCREDS); in proc_mem_open()
803 put_task_struct(task); in proc_mem_open()
1041 struct task_struct *task = get_proc_task(file_inode(file)); in oom_adj_read() local
1046 if (!task) in oom_adj_read()
1048 if (task->signal->oom_score_adj == OOM_SCORE_ADJ_MAX) in oom_adj_read()
1051 oom_adj = (task->signal->oom_score_adj * -OOM_DISABLE) / in oom_adj_read()
1053 put_task_struct(task); in oom_adj_read()
1063 struct task_struct *task; in __set_oom_adj() local
1066 task = get_proc_task(file_inode(file)); in __set_oom_adj()
1067 if (!task) in __set_oom_adj()
1072 if (oom_adj < task->signal->oom_score_adj && in __set_oom_adj()
1082 current->comm, task_pid_nr(current), task_pid_nr(task), in __set_oom_adj()
1083 task_pid_nr(task)); in __set_oom_adj()
1085 if ((short)oom_adj < task->signal->oom_score_adj_min && in __set_oom_adj()
1097 if (!task->vfork_done) { in __set_oom_adj()
1098 struct task_struct *p = find_lock_task_mm(task); in __set_oom_adj()
1109 task->signal->oom_score_adj = oom_adj; in __set_oom_adj()
1111 task->signal->oom_score_adj_min = (short)oom_adj; in __set_oom_adj()
1112 trace_oom_score_adj_update(task); in __set_oom_adj()
1119 if (same_thread_group(task, p)) in __set_oom_adj()
1139 put_task_struct(task); in __set_oom_adj()
1200 struct task_struct *task = get_proc_task(file_inode(file)); in oom_score_adj_read() local
1205 if (!task) in oom_score_adj_read()
1207 oom_score_adj = task->signal->oom_score_adj; in oom_score_adj_read()
1208 put_task_struct(task); in oom_score_adj_read()
1254 struct task_struct *task = get_proc_task(inode); in proc_loginuid_read() local
1258 if (!task) in proc_loginuid_read()
1262 audit_get_loginuid(task))); in proc_loginuid_read()
1263 put_task_struct(task); in proc_loginuid_read()
1320 struct task_struct *task = get_proc_task(inode); in proc_sessionid_read() local
1324 if (!task) in proc_sessionid_read()
1327 audit_get_sessionid(task)); in proc_sessionid_read()
1328 put_task_struct(task); in proc_sessionid_read()
1342 struct task_struct *task = get_proc_task(file_inode(file)); in proc_fault_inject_read() local
1347 if (!task) in proc_fault_inject_read()
1349 make_it_fail = task->make_it_fail; in proc_fault_inject_read()
1350 put_task_struct(task); in proc_fault_inject_read()
1360 struct task_struct *task; in proc_fault_inject_write() local
1378 task = get_proc_task(file_inode(file)); in proc_fault_inject_write()
1379 if (!task) in proc_fault_inject_write()
1381 task->make_it_fail = make_it_fail; in proc_fault_inject_write()
1382 put_task_struct(task); in proc_fault_inject_write()
1396 struct task_struct *task; in proc_fail_nth_write() local
1404 task = get_proc_task(file_inode(file)); in proc_fail_nth_write()
1405 if (!task) in proc_fail_nth_write()
1407 task->fail_nth = n; in proc_fail_nth_write()
1408 put_task_struct(task); in proc_fail_nth_write()
1416 struct task_struct *task; in proc_fail_nth_read() local
1420 task = get_proc_task(file_inode(file)); in proc_fail_nth_read()
1421 if (!task) in proc_fail_nth_read()
1423 len = snprintf(numbuf, sizeof(numbuf), "%u\n", task->fail_nth); in proc_fail_nth_read()
1424 put_task_struct(task); in proc_fail_nth_read()
1437 * Print out various scheduling related per-task fields:
1724 struct task_struct *task; in proc_exe_link() local
1727 task = get_proc_task(d_inode(dentry)); in proc_exe_link()
1728 if (!task) in proc_exe_link()
1730 exe_file = get_task_exe_file(task); in proc_exe_link()
1731 put_task_struct(task); in proc_exe_link()
1817 void task_dump_owner(struct task_struct *task, umode_t mode, in task_dump_owner() argument
1821 * proc file for a task. in task_dump_owner()
1827 if (unlikely(task->flags & PF_KTHREAD)) { in task_dump_owner()
1835 cred = __task_cred(task); in task_dump_owner()
1850 task_lock(task); in task_dump_owner()
1851 mm = task->mm; in task_dump_owner()
1869 task_unlock(task); in task_dump_owner()
1889 struct task_struct *task, umode_t mode) in proc_pid_make_inode() argument
1909 * grab the reference to task. in proc_pid_make_inode()
1911 pid = get_task_pid(task, PIDTYPE_PID); in proc_pid_make_inode()
1918 task_dump_owner(task, 0, &inode->i_uid, &inode->i_gid); in proc_pid_make_inode()
1919 security_task_to_inode(task, inode); in proc_pid_make_inode()
1930 * Generating an inode and adding it into @pid->inodes, so that task will
1934 * '/proc/<tgid>/task'. Other entries(eg. fd, stat) under '/proc/<tgid>'
1936 * In theory, dentries under '/proc/<tgid>/task' can also be released by
1939 * '/proc/<tgid>/task/<pid>' dentry before released.
1942 struct task_struct *task, umode_t mode) in proc_pid_make_base_inode() argument
1948 inode = proc_pid_make_inode(sb, task, mode); in proc_pid_make_base_inode()
1967 struct task_struct *task; in pid_getattr() local
1974 task = pid_task(proc_pid(inode), PIDTYPE_PID); in pid_getattr()
1975 if (task) { in pid_getattr()
1976 if (!has_pid_permissions(fs_info, task, HIDEPID_INVISIBLE)) { in pid_getattr()
1984 task_dump_owner(task, inode->i_mode, &stat->uid, &stat->gid); in pid_getattr()
1995 void pid_update_inode(struct task_struct *task, struct inode *inode) in pid_update_inode() argument
1997 task_dump_owner(task, inode->i_mode, &inode->i_uid, &inode->i_gid); in pid_update_inode()
2000 security_task_to_inode(task, inode); in pid_update_inode()
2004 * Rewrite the inode's ownerships here because the owning task may have
2011 struct task_struct *task; in pid_revalidate() local
2018 task = pid_task(proc_pid(inode), PIDTYPE_PID); in pid_revalidate()
2020 if (task) { in pid_revalidate()
2021 pid_update_inode(task, inode); in pid_revalidate()
2036 /* Is the task we represent dead? in pid_delete_dentry()
2065 instantiate_t instantiate, struct task_struct *task, const void *ptr) in proc_fill_cache() argument
2081 res = instantiate(child, task, ptr); in proc_fill_cache()
2146 struct task_struct *task; in map_files_d_revalidate() local
2154 task = get_proc_task(inode); in map_files_d_revalidate()
2155 if (!task) in map_files_d_revalidate()
2158 mm = mm_access(task, PTRACE_MODE_READ_FSCREDS); in map_files_d_revalidate()
2174 task_dump_owner(task, 0, &inode->i_uid, &inode->i_gid); in map_files_d_revalidate()
2176 security_task_to_inode(task, inode); in map_files_d_revalidate()
2181 put_task_struct(task); in map_files_d_revalidate()
2196 struct task_struct *task; in map_files_get_link() local
2201 task = get_proc_task(d_inode(dentry)); in map_files_get_link()
2202 if (!task) in map_files_get_link()
2205 mm = get_task_mm(task); in map_files_get_link()
2206 put_task_struct(task); in map_files_get_link()
2266 struct task_struct *task, const void *ptr) in proc_map_files_instantiate() argument
2272 inode = proc_pid_make_inode(dentry->d_sb, task, S_IFLNK | in proc_map_files_instantiate()
2293 struct task_struct *task; in proc_map_files_lookup() local
2298 task = get_proc_task(dir); in proc_map_files_lookup()
2299 if (!task) in proc_map_files_lookup()
2303 if (!ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS)) in proc_map_files_lookup()
2310 mm = get_task_mm(task); in proc_map_files_lookup()
2324 result = proc_map_files_instantiate(dentry, task, in proc_map_files_lookup()
2332 put_task_struct(task); in proc_map_files_lookup()
2347 struct task_struct *task; in proc_map_files_readdir() local
2358 task = get_proc_task(file_inode(file)); in proc_map_files_readdir()
2359 if (!task) in proc_map_files_readdir()
2363 if (!ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS)) in proc_map_files_readdir()
2370 mm = get_task_mm(task); in proc_map_files_readdir()
2424 task, in proc_map_files_readdir()
2431 put_task_struct(task); in proc_map_files_readdir()
2446 struct task_struct *task; member
2456 tp->task = get_pid_task(tp->pid, PIDTYPE_PID); in timers_start()
2457 if (!tp->task) in timers_start()
2460 tp->sighand = lock_task_sighand(tp->task, &tp->flags); in timers_start()
2464 return seq_list_start(&tp->task->signal->posix_timers, *pos); in timers_start()
2470 return seq_list_next(v, &tp->task->signal->posix_timers, pos); in timers_next()
2478 unlock_task_sighand(tp->task, &tp->flags); in timers_stop()
2482 if (tp->task) { in timers_stop()
2483 put_task_struct(tp->task); in timers_stop()
2484 tp->task = NULL; in timers_stop()
2637 struct task_struct *task, const void *ptr) in proc_pident_instantiate() argument
2643 inode = proc_pid_make_inode(dentry->d_sb, task, p->mode); in proc_pident_instantiate()
2655 pid_update_inode(task, inode); in proc_pident_instantiate()
2665 struct task_struct *task = get_proc_task(dir); in proc_pident_lookup() local
2668 if (!task) in proc_pident_lookup()
2679 res = proc_pident_instantiate(dentry, task, p); in proc_pident_lookup()
2683 put_task_struct(task); in proc_pident_lookup()
2691 struct task_struct *task = get_proc_task(file_inode(file)); in proc_pident_readdir() local
2694 if (!task) in proc_pident_readdir()
2705 proc_pident_instantiate, task, p)) in proc_pident_readdir()
2710 put_task_struct(task); in proc_pident_readdir()
2728 struct task_struct *task = get_proc_task(inode); in proc_pid_attr_read() local
2730 if (!task) in proc_pid_attr_read()
2733 length = security_getprocattr(task, PROC_I(inode)->op.lsm, in proc_pid_attr_read()
2736 put_task_struct(task); in proc_pid_attr_read()
2747 struct task_struct *task; in proc_pid_attr_write() local
2751 /* A task may only write when it was the opener. */ in proc_pid_attr_write()
2756 task = pid_task(proc_pid(inode), PIDTYPE_PID); in proc_pid_attr_write()
2757 if (!task) { in proc_pid_attr_write()
2761 /* A task may only write its own attributes. */ in proc_pid_attr_write()
2762 if (current != task) { in proc_pid_attr_write()
2903 struct task_struct *task = get_proc_task(file_inode(file)); in proc_coredump_filter_read() local
2909 if (!task) in proc_coredump_filter_read()
2913 mm = get_task_mm(task); in proc_coredump_filter_read()
2922 put_task_struct(task); in proc_coredump_filter_read()
2932 struct task_struct *task; in proc_coredump_filter_write() local
2944 task = get_proc_task(file_inode(file)); in proc_coredump_filter_write()
2945 if (!task) in proc_coredump_filter_write()
2948 mm = get_task_mm(task); in proc_coredump_filter_write()
2962 put_task_struct(task); in proc_coredump_filter_write()
2977 static int do_io_accounting(struct task_struct *task, struct seq_file *m, int whole) in do_io_accounting() argument
2979 struct task_io_accounting acct = task->ioac; in do_io_accounting()
2983 result = down_read_killable(&task->signal->exec_update_lock); in do_io_accounting()
2987 if (!ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS)) { in do_io_accounting()
2992 if (whole && lock_task_sighand(task, &flags)) { in do_io_accounting()
2993 struct task_struct *t = task; in do_io_accounting()
2995 task_io_accounting_add(&acct, &task->signal->ioac); in do_io_accounting()
2996 while_each_thread(task, t) in do_io_accounting()
2999 unlock_task_sighand(task, &flags); in do_io_accounting()
3019 up_read(&task->signal->exec_update_lock); in do_io_accounting()
3024 struct pid *pid, struct task_struct *task) in proc_tid_io_accounting() argument
3026 return do_io_accounting(task, m, 0); in proc_tid_io_accounting()
3030 struct pid *pid, struct task_struct *task) in proc_tgid_io_accounting() argument
3032 return do_io_accounting(task, m, 1); in proc_tgid_io_accounting()
3041 struct task_struct *task; in proc_id_map_open() local
3045 task = get_proc_task(inode); in proc_id_map_open()
3046 if (task) { in proc_id_map_open()
3048 ns = get_user_ns(task_cred_xxx(task, user_ns)); in proc_id_map_open()
3050 put_task_struct(task); in proc_id_map_open()
3119 struct task_struct *task; in proc_setgroups_open() local
3123 task = get_proc_task(inode); in proc_setgroups_open()
3124 if (task) { in proc_setgroups_open()
3126 ns = get_user_ns(task_cred_xxx(task, user_ns)); in proc_setgroups_open()
3128 put_task_struct(task); in proc_setgroups_open()
3169 struct pid *pid, struct task_struct *task) in proc_pid_personality() argument
3171 int err = lock_trace(task); in proc_pid_personality()
3173 seq_printf(m, "%08x\n", task->personality); in proc_pid_personality()
3174 unlock_trace(task); in proc_pid_personality()
3181 struct pid *pid, struct task_struct *task) in proc_pid_patch_state() argument
3183 seq_printf(m, "%d\n", task->patch_state); in proc_pid_patch_state()
3190 struct pid *pid, struct task_struct *task) in proc_pid_ksm_merging_pages() argument
3194 mm = get_task_mm(task); in proc_pid_ksm_merging_pages()
3203 struct pid *pid, struct task_struct *task) in proc_pid_ksm_stat() argument
3207 mm = get_task_mm(task); in proc_pid_ksm_stat()
3219 struct pid *pid, struct task_struct *task) in proc_stack_depth() argument
3222 (task->prev_lowest_stack & (THREAD_SIZE - 1)); in proc_stack_depth()
3224 (task->lowest_stack & (THREAD_SIZE - 1)); in proc_stack_depth()
3239 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
3396 * It is safe and reasonable to cache /proc entries for a task until
3397 * that task exits. After that they just clog up the dcache with
3413 struct task_struct *task, const void *ptr) in proc_pid_instantiate() argument
3417 inode = proc_pid_make_base_inode(dentry->d_sb, task, in proc_pid_instantiate()
3427 pid_update_inode(task, inode); in proc_pid_instantiate()
3435 struct task_struct *task; in proc_pid_lookup() local
3448 task = find_task_by_pid_ns(tgid, ns); in proc_pid_lookup()
3449 if (task) in proc_pid_lookup()
3450 get_task_struct(task); in proc_pid_lookup()
3452 if (!task) in proc_pid_lookup()
3457 if (!has_pid_permissions(fs_info, task, HIDEPID_NO_ACCESS)) in proc_pid_lookup()
3461 result = proc_pid_instantiate(dentry, task, NULL); in proc_pid_lookup()
3463 put_task_struct(task); in proc_pid_lookup()
3469 * Find the first task with tgid >= tgid
3474 struct task_struct *task; member
3480 if (iter.task) in next_tgid()
3481 put_task_struct(iter.task); in next_tgid()
3484 iter.task = NULL; in next_tgid()
3488 iter.task = pid_task(pid, PIDTYPE_TGID); in next_tgid()
3489 if (!iter.task) { in next_tgid()
3493 get_task_struct(iter.task); in next_tgid()
3525 iter.task = NULL; in proc_pid_readdir()
3527 iter.task; in proc_pid_readdir()
3533 if (!has_pid_permissions(fs_info, iter.task, HIDEPID_INVISIBLE)) in proc_pid_readdir()
3539 proc_pid_instantiate, iter.task, NULL)) { in proc_pid_readdir()
3540 put_task_struct(iter.task); in proc_pid_readdir()
3550 * used for the node /proc/<pid>/task/<tid>/comm.
3551 * It bypasses generic permission checks in the case where a task of the same
3552 * task group attempts to access the node.
3564 struct task_struct *task; in proc_tid_comm_permission() local
3566 task = get_proc_task(inode); in proc_tid_comm_permission()
3567 if (!task) in proc_tid_comm_permission()
3569 is_same_tgroup = same_thread_group(current, task); in proc_tid_comm_permission()
3570 put_task_struct(task); in proc_tid_comm_permission()
3573 /* This file (/proc/<pid>/task/<tid>/comm) can always be in proc_tid_comm_permission()
3718 struct task_struct *task, const void *ptr) in proc_task_instantiate() argument
3721 inode = proc_pid_make_base_inode(dentry->d_sb, task, in proc_task_instantiate()
3731 pid_update_inode(task, inode); in proc_task_instantiate()
3739 struct task_struct *task; in proc_task_lookup() local
3756 task = find_task_by_pid_ns(tid, ns); in proc_task_lookup()
3757 if (task) in proc_task_lookup()
3758 get_task_struct(task); in proc_task_lookup()
3760 if (!task) in proc_task_lookup()
3762 if (!same_thread_group(leader, task)) in proc_task_lookup()
3765 result = proc_task_instantiate(dentry, task, NULL); in proc_task_lookup()
3767 put_task_struct(task); in proc_task_lookup()
3789 struct task_struct *pos, *task; in first_tid() local
3796 task = pid_task(pid, PIDTYPE_PID); in first_tid()
3797 if (!task) in first_tid()
3803 if (pos && same_thread_group(pos, task)) in first_tid()
3808 if (nr >= get_nr_threads(task)) in first_tid()
3814 pos = task = task->group_leader; in first_tid()
3818 } while_each_thread(task, pos); in first_tid()
3851 /* for the /proc/TGID/task/ directories */
3855 struct task_struct *task; in proc_task_readdir() local
3871 for (task = first_tid(proc_pid(inode), tid, ctx->pos - 2, ns); in proc_task_readdir()
3872 task; in proc_task_readdir()
3873 task = next_tid(task), ctx->pos++) { in proc_task_readdir()
3877 tid = task_pid_nr_ns(task, ns); in proc_task_readdir()
3879 continue; /* The task has just exited. */ in proc_task_readdir()
3882 proc_task_instantiate, task, NULL)) { in proc_task_readdir()
3886 put_task_struct(task); in proc_task_readdir()