Lines Matching refs:task

209 static int get_task_root(struct task_struct *task, struct path *root)  in get_task_root()  argument
213 task_lock(task); in get_task_root()
214 if (task->fs) { in get_task_root()
215 get_fs_root(task->fs, root); in get_task_root()
218 task_unlock(task); in get_task_root()
224 struct task_struct *task = get_proc_task(d_inode(dentry)); in proc_cwd_link() local
227 if (task) { in proc_cwd_link()
228 task_lock(task); in proc_cwd_link()
229 if (task->fs) { in proc_cwd_link()
230 get_fs_pwd(task->fs, path); in proc_cwd_link()
233 task_unlock(task); in proc_cwd_link()
234 put_task_struct(task); in proc_cwd_link()
241 struct task_struct *task = get_proc_task(d_inode(dentry)); in proc_root_link() local
244 if (task) { in proc_root_link()
245 result = get_task_root(task, path); in proc_root_link()
246 put_task_struct(task); in proc_root_link()
423 struct pid *pid, struct task_struct *task) in proc_pid_wchan() argument
428 if (!ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS)) in proc_pid_wchan()
431 wchan = get_wchan(task); in proc_pid_wchan()
443 static int lock_trace(struct task_struct *task) in lock_trace() argument
445 int err = down_read_killable(&task->signal->exec_update_lock); in lock_trace()
448 if (!ptrace_may_access(task, PTRACE_MODE_ATTACH_FSCREDS)) { in lock_trace()
449 up_read(&task->signal->exec_update_lock); in lock_trace()
455 static void unlock_trace(struct task_struct *task) in unlock_trace() argument
457 up_read(&task->signal->exec_update_lock); in unlock_trace()
465 struct pid *pid, struct task_struct *task) in proc_pid_stack() argument
489 err = lock_trace(task); in proc_pid_stack()
493 nr_entries = stack_trace_save_tsk(task, entries, in proc_pid_stack()
500 unlock_trace(task); in proc_pid_stack()
513 struct pid *pid, struct task_struct *task) in proc_pid_schedstat() argument
519 (unsigned long long)task->se.sum_exec_runtime, in proc_pid_schedstat()
520 (unsigned long long)task->sched_info.run_delay, in proc_pid_schedstat()
521 task->sched_info.pcount); in proc_pid_schedstat()
532 struct task_struct *task = get_proc_task(inode); in lstats_show_proc() local
534 if (!task) in lstats_show_proc()
538 struct latency_record *lr = &task->latency_record[i]; in lstats_show_proc()
554 put_task_struct(task); in lstats_show_proc()
566 struct task_struct *task = get_proc_task(file_inode(file)); in lstats_write() local
568 if (!task) in lstats_write()
570 clear_tsk_latency_tracing(task); in lstats_write()
571 put_task_struct(task); in lstats_write()
587 struct pid *pid, struct task_struct *task) in proc_oom_score() argument
593 badness = oom_badness(task, totalpages); in proc_oom_score()
633 struct pid *pid, struct task_struct *task) in proc_pid_limits() argument
640 if (!lock_task_sighand(task, &flags)) in proc_pid_limits()
642 memcpy(rlim, task->signal->rlim, sizeof(struct rlimit) * RLIM_NLIMITS); in proc_pid_limits()
643 unlock_task_sighand(task, &flags); in proc_pid_limits()
677 struct pid *pid, struct task_struct *task) in proc_pid_syscall() argument
683 res = lock_trace(task); in proc_pid_syscall()
687 if (task_current_syscall(task, &info)) in proc_pid_syscall()
698 unlock_trace(task); in proc_pid_syscall()
711 struct task_struct *task; in proc_fd_access_allowed() local
717 task = get_proc_task(inode); in proc_fd_access_allowed()
718 if (task) { in proc_fd_access_allowed()
719 allowed = ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS); in proc_fd_access_allowed()
720 put_task_struct(task); in proc_fd_access_allowed()
747 struct task_struct *task, in has_pid_permissions() argument
756 return ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS); in has_pid_permissions()
762 return ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS); in has_pid_permissions()
770 struct task_struct *task; in proc_pid_permission() local
773 task = get_proc_task(inode); in proc_pid_permission()
774 if (!task) in proc_pid_permission()
776 has_perms = has_pid_permissions(fs_info, task, HIDEPID_NO_ACCESS); in proc_pid_permission()
777 put_task_struct(task); in proc_pid_permission()
806 struct task_struct *task; in proc_single_show() local
809 task = get_pid_task(pid, PIDTYPE_PID); in proc_single_show()
810 if (!task) in proc_single_show()
813 ret = PROC_I(inode)->op.proc_show(m, ns, pid, task); in proc_single_show()
815 put_task_struct(task); in proc_single_show()
834 struct task_struct *task = get_proc_task(inode); in proc_mem_open() local
837 if (task) { in proc_mem_open()
838 mm = mm_access(task, mode | PTRACE_MODE_FSCREDS); in proc_mem_open()
839 put_task_struct(task); in proc_mem_open()
872 struct task_struct *task; in proc_mem_foll_force() local
879 task = get_proc_task(file_inode(file)); in proc_mem_foll_force()
880 if (task) { in proc_mem_foll_force()
881 ptrace_active = READ_ONCE(task->ptrace) && in proc_mem_foll_force()
882 READ_ONCE(task->mm) == mm && in proc_mem_foll_force()
883 READ_ONCE(task->parent) == current; in proc_mem_foll_force()
884 put_task_struct(task); in proc_mem_foll_force()
1099 struct task_struct *task = get_proc_task(file_inode(file)); in oom_adj_read() local
1104 if (!task) in oom_adj_read()
1106 if (task->signal->oom_score_adj == OOM_SCORE_ADJ_MAX) in oom_adj_read()
1109 oom_adj = (task->signal->oom_score_adj * -OOM_DISABLE) / in oom_adj_read()
1111 put_task_struct(task); in oom_adj_read()
1121 struct task_struct *task; in __set_oom_adj() local
1124 task = get_proc_task(file_inode(file)); in __set_oom_adj()
1125 if (!task) in __set_oom_adj()
1130 if (oom_adj < task->signal->oom_score_adj && in __set_oom_adj()
1140 current->comm, task_pid_nr(current), task_pid_nr(task), in __set_oom_adj()
1141 task_pid_nr(task)); in __set_oom_adj()
1143 if ((short)oom_adj < task->signal->oom_score_adj_min && in __set_oom_adj()
1155 if (!task->vfork_done) { in __set_oom_adj()
1156 struct task_struct *p = find_lock_task_mm(task); in __set_oom_adj()
1167 task->signal->oom_score_adj = oom_adj; in __set_oom_adj()
1169 task->signal->oom_score_adj_min = (short)oom_adj; in __set_oom_adj()
1170 trace_oom_score_adj_update(task); in __set_oom_adj()
1177 if (same_thread_group(task, p)) in __set_oom_adj()
1197 put_task_struct(task); in __set_oom_adj()
1257 struct task_struct *task = get_proc_task(file_inode(file)); in oom_score_adj_read() local
1262 if (!task) in oom_score_adj_read()
1264 oom_score_adj = task->signal->oom_score_adj; in oom_score_adj_read()
1265 put_task_struct(task); in oom_score_adj_read()
1310 struct task_struct *task = get_proc_task(inode); in proc_loginuid_read() local
1314 if (!task) in proc_loginuid_read()
1318 audit_get_loginuid(task))); in proc_loginuid_read()
1319 put_task_struct(task); in proc_loginuid_read()
1376 struct task_struct *task = get_proc_task(inode); in proc_sessionid_read() local
1380 if (!task) in proc_sessionid_read()
1383 audit_get_sessionid(task)); in proc_sessionid_read()
1384 put_task_struct(task); in proc_sessionid_read()
1398 struct task_struct *task = get_proc_task(file_inode(file)); in proc_fault_inject_read() local
1403 if (!task) in proc_fault_inject_read()
1405 make_it_fail = task->make_it_fail; in proc_fault_inject_read()
1406 put_task_struct(task); in proc_fault_inject_read()
1416 struct task_struct *task; in proc_fault_inject_write() local
1434 task = get_proc_task(file_inode(file)); in proc_fault_inject_write()
1435 if (!task) in proc_fault_inject_write()
1437 task->make_it_fail = make_it_fail; in proc_fault_inject_write()
1438 put_task_struct(task); in proc_fault_inject_write()
1452 struct task_struct *task; in proc_fail_nth_write() local
1460 task = get_proc_task(file_inode(file)); in proc_fail_nth_write()
1461 if (!task) in proc_fail_nth_write()
1463 task->fail_nth = n; in proc_fail_nth_write()
1464 put_task_struct(task); in proc_fail_nth_write()
1472 struct task_struct *task; in proc_fail_nth_read() local
1476 task = get_proc_task(file_inode(file)); in proc_fail_nth_read()
1477 if (!task) in proc_fail_nth_read()
1479 len = snprintf(numbuf, sizeof(numbuf), "%u\n", task->fail_nth); in proc_fail_nth_read()
1480 put_task_struct(task); in proc_fail_nth_read()
1778 struct task_struct *task; in proc_exe_link() local
1781 task = get_proc_task(d_inode(dentry)); in proc_exe_link()
1782 if (!task) in proc_exe_link()
1784 exe_file = get_task_exe_file(task); in proc_exe_link()
1785 put_task_struct(task); in proc_exe_link()
1871 void task_dump_owner(struct task_struct *task, umode_t mode, in task_dump_owner() argument
1881 if (unlikely(task->flags & PF_KTHREAD)) { in task_dump_owner()
1889 cred = __task_cred(task); in task_dump_owner()
1904 task_lock(task); in task_dump_owner()
1905 mm = task->mm; in task_dump_owner()
1923 task_unlock(task); in task_dump_owner()
1941 struct task_struct *task, umode_t mode) in proc_pid_make_inode() argument
1963 pid = get_task_pid(task, PIDTYPE_PID); in proc_pid_make_inode()
1970 task_dump_owner(task, 0, &inode->i_uid, &inode->i_gid); in proc_pid_make_inode()
1971 security_task_to_inode(task, inode); in proc_pid_make_inode()
1994 struct task_struct *task, umode_t mode) in proc_pid_make_base_inode() argument
2000 inode = proc_pid_make_inode(sb, task, mode); in proc_pid_make_base_inode()
2019 struct task_struct *task; in pid_getattr() local
2026 task = pid_task(proc_pid(inode), PIDTYPE_PID); in pid_getattr()
2027 if (task) { in pid_getattr()
2028 if (!has_pid_permissions(fs_info, task, HIDEPID_INVISIBLE)) { in pid_getattr()
2036 task_dump_owner(task, inode->i_mode, &stat->uid, &stat->gid); in pid_getattr()
2047 void pid_update_inode(struct task_struct *task, struct inode *inode) in pid_update_inode() argument
2049 task_dump_owner(task, inode->i_mode, &inode->i_uid, &inode->i_gid); in pid_update_inode()
2052 security_task_to_inode(task, inode); in pid_update_inode()
2063 struct task_struct *task; in pid_revalidate() local
2070 task = pid_task(proc_pid(inode), PIDTYPE_PID); in pid_revalidate()
2072 if (task) { in pid_revalidate()
2073 pid_update_inode(task, inode); in pid_revalidate()
2117 instantiate_t instantiate, struct task_struct *task, const void *ptr) in proc_fill_cache() argument
2133 res = instantiate(child, task, ptr); in proc_fill_cache()
2198 struct task_struct *task; in map_files_d_revalidate() local
2206 task = get_proc_task(inode); in map_files_d_revalidate()
2207 if (!task) in map_files_d_revalidate()
2210 mm = mm_access(task, PTRACE_MODE_READ_FSCREDS); in map_files_d_revalidate()
2226 task_dump_owner(task, 0, &inode->i_uid, &inode->i_gid); in map_files_d_revalidate()
2228 security_task_to_inode(task, inode); in map_files_d_revalidate()
2233 put_task_struct(task); in map_files_d_revalidate()
2248 struct task_struct *task; in map_files_get_link() local
2253 task = get_proc_task(d_inode(dentry)); in map_files_get_link()
2254 if (!task) in map_files_get_link()
2257 mm = get_task_mm(task); in map_files_get_link()
2258 put_task_struct(task); in map_files_get_link()
2318 struct task_struct *task, const void *ptr) in proc_map_files_instantiate() argument
2324 inode = proc_pid_make_inode(dentry->d_sb, task, S_IFLNK | in proc_map_files_instantiate()
2345 struct task_struct *task; in proc_map_files_lookup() local
2350 task = get_proc_task(dir); in proc_map_files_lookup()
2351 if (!task) in proc_map_files_lookup()
2355 if (!ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS)) in proc_map_files_lookup()
2362 mm = get_task_mm(task); in proc_map_files_lookup()
2376 result = proc_map_files_instantiate(dentry, task, in proc_map_files_lookup()
2384 put_task_struct(task); in proc_map_files_lookup()
2399 struct task_struct *task; in proc_map_files_readdir() local
2410 task = get_proc_task(file_inode(file)); in proc_map_files_readdir()
2411 if (!task) in proc_map_files_readdir()
2415 if (!ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS)) in proc_map_files_readdir()
2422 mm = get_task_mm(task); in proc_map_files_readdir()
2476 task, in proc_map_files_readdir()
2483 put_task_struct(task); in proc_map_files_readdir()
2498 struct task_struct *task; member
2508 tp->task = get_pid_task(tp->pid, PIDTYPE_PID); in timers_start()
2509 if (!tp->task) in timers_start()
2512 tp->sighand = lock_task_sighand(tp->task, &tp->flags); in timers_start()
2516 return seq_hlist_start(&tp->task->signal->posix_timers, *pos); in timers_start()
2522 return seq_hlist_next(v, &tp->task->signal->posix_timers, pos); in timers_next()
2530 unlock_task_sighand(tp->task, &tp->flags); in timers_stop()
2534 if (tp->task) { in timers_stop()
2535 put_task_struct(tp->task); in timers_stop()
2536 tp->task = NULL; in timers_stop()
2690 struct task_struct *task, const void *ptr) in proc_pident_instantiate() argument
2696 inode = proc_pid_make_inode(dentry->d_sb, task, p->mode); in proc_pident_instantiate()
2708 pid_update_inode(task, inode); in proc_pident_instantiate()
2718 struct task_struct *task = get_proc_task(dir); in proc_pident_lookup() local
2721 if (!task) in proc_pident_lookup()
2732 res = proc_pident_instantiate(dentry, task, p); in proc_pident_lookup()
2736 put_task_struct(task); in proc_pident_lookup()
2744 struct task_struct *task = get_proc_task(file_inode(file)); in proc_pident_readdir() local
2747 if (!task) in proc_pident_readdir()
2758 proc_pident_instantiate, task, p)) in proc_pident_readdir()
2763 put_task_struct(task); in proc_pident_readdir()
2781 struct task_struct *task = get_proc_task(inode); in proc_pid_attr_read() local
2783 if (!task) in proc_pid_attr_read()
2786 length = security_getprocattr(task, PROC_I(inode)->op.lsmid, in proc_pid_attr_read()
2789 put_task_struct(task); in proc_pid_attr_read()
2800 struct task_struct *task; in proc_pid_attr_write() local
2809 task = pid_task(proc_pid(inode), PIDTYPE_PID); in proc_pid_attr_write()
2810 if (!task) { in proc_pid_attr_write()
2815 if (current != task) { in proc_pid_attr_write()
2956 struct task_struct *task = get_proc_task(file_inode(file)); in proc_coredump_filter_read() local
2962 if (!task) in proc_coredump_filter_read()
2966 mm = get_task_mm(task); in proc_coredump_filter_read()
2975 put_task_struct(task); in proc_coredump_filter_read()
2985 struct task_struct *task; in proc_coredump_filter_write() local
2997 task = get_proc_task(file_inode(file)); in proc_coredump_filter_write()
2998 if (!task) in proc_coredump_filter_write()
3001 mm = get_task_mm(task); in proc_coredump_filter_write()
3015 put_task_struct(task); in proc_coredump_filter_write()
3030 static int do_io_accounting(struct task_struct *task, struct seq_file *m, int whole) in do_io_accounting() argument
3035 result = down_read_killable(&task->signal->exec_update_lock); in do_io_accounting()
3039 if (!ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS)) { in do_io_accounting()
3045 struct signal_struct *sig = task->signal; in do_io_accounting()
3063 acct = task->ioac; in do_io_accounting()
3084 up_read(&task->signal->exec_update_lock); in do_io_accounting()
3089 struct pid *pid, struct task_struct *task) in proc_tid_io_accounting() argument
3091 return do_io_accounting(task, m, 0); in proc_tid_io_accounting()
3095 struct pid *pid, struct task_struct *task) in proc_tgid_io_accounting() argument
3097 return do_io_accounting(task, m, 1); in proc_tgid_io_accounting()
3106 struct task_struct *task; in proc_id_map_open() local
3110 task = get_proc_task(inode); in proc_id_map_open()
3111 if (task) { in proc_id_map_open()
3113 ns = get_user_ns(task_cred_xxx(task, user_ns)); in proc_id_map_open()
3115 put_task_struct(task); in proc_id_map_open()
3184 struct task_struct *task; in proc_setgroups_open() local
3188 task = get_proc_task(inode); in proc_setgroups_open()
3189 if (task) { in proc_setgroups_open()
3191 ns = get_user_ns(task_cred_xxx(task, user_ns)); in proc_setgroups_open()
3193 put_task_struct(task); in proc_setgroups_open()
3234 struct pid *pid, struct task_struct *task) in proc_pid_personality() argument
3236 int err = lock_trace(task); in proc_pid_personality()
3238 seq_printf(m, "%08x\n", task->personality); in proc_pid_personality()
3239 unlock_trace(task); in proc_pid_personality()
3246 struct pid *pid, struct task_struct *task) in proc_pid_patch_state() argument
3248 seq_printf(m, "%d\n", task->patch_state); in proc_pid_patch_state()
3255 struct pid *pid, struct task_struct *task) in proc_pid_ksm_merging_pages() argument
3259 mm = get_task_mm(task); in proc_pid_ksm_merging_pages()
3268 struct pid *pid, struct task_struct *task) in proc_pid_ksm_stat() argument
3272 mm = get_task_mm(task); in proc_pid_ksm_stat()
3287 struct pid *pid, struct task_struct *task) in proc_stack_depth() argument
3290 (task->prev_lowest_stack & (THREAD_SIZE - 1)); in proc_stack_depth()
3292 (task->lowest_stack & (THREAD_SIZE - 1)); in proc_stack_depth()
3481 struct task_struct *task, const void *ptr) in proc_pid_instantiate() argument
3485 inode = proc_pid_make_base_inode(dentry->d_sb, task, in proc_pid_instantiate()
3495 pid_update_inode(task, inode); in proc_pid_instantiate()
3503 struct task_struct *task; in proc_pid_lookup() local
3516 task = find_task_by_pid_ns(tgid, ns); in proc_pid_lookup()
3517 if (task) in proc_pid_lookup()
3518 get_task_struct(task); in proc_pid_lookup()
3520 if (!task) in proc_pid_lookup()
3525 if (!has_pid_permissions(fs_info, task, HIDEPID_NO_ACCESS)) in proc_pid_lookup()
3529 result = proc_pid_instantiate(dentry, task, NULL); in proc_pid_lookup()
3531 put_task_struct(task); in proc_pid_lookup()
3542 struct task_struct *task; member
3548 if (iter.task) in next_tgid()
3549 put_task_struct(iter.task); in next_tgid()
3552 iter.task = NULL; in next_tgid()
3556 iter.task = pid_task(pid, PIDTYPE_TGID); in next_tgid()
3557 if (!iter.task) { in next_tgid()
3561 get_task_struct(iter.task); in next_tgid()
3593 iter.task = NULL; in proc_pid_readdir()
3595 iter.task; in proc_pid_readdir()
3601 if (!has_pid_permissions(fs_info, iter.task, HIDEPID_INVISIBLE)) in proc_pid_readdir()
3607 proc_pid_instantiate, iter.task, NULL)) { in proc_pid_readdir()
3608 put_task_struct(iter.task); in proc_pid_readdir()
3632 struct task_struct *task; in proc_tid_comm_permission() local
3634 task = get_proc_task(inode); in proc_tid_comm_permission()
3635 if (!task) in proc_tid_comm_permission()
3637 is_same_tgroup = same_thread_group(current, task); in proc_tid_comm_permission()
3638 put_task_struct(task); in proc_tid_comm_permission()
3787 struct task_struct *task, const void *ptr) in proc_task_instantiate() argument
3790 inode = proc_pid_make_base_inode(dentry->d_sb, task, in proc_task_instantiate()
3800 pid_update_inode(task, inode); in proc_task_instantiate()
3808 struct task_struct *task; in proc_task_lookup() local
3825 task = find_task_by_pid_ns(tid, ns); in proc_task_lookup()
3826 if (task) in proc_task_lookup()
3827 get_task_struct(task); in proc_task_lookup()
3829 if (!task) in proc_task_lookup()
3831 if (!same_thread_group(leader, task)) in proc_task_lookup()
3834 result = proc_task_instantiate(dentry, task, NULL); in proc_task_lookup()
3836 put_task_struct(task); in proc_task_lookup()
3858 struct task_struct *pos, *task; in first_tid() local
3865 task = pid_task(pid, PIDTYPE_PID); in first_tid()
3866 if (!task) in first_tid()
3872 if (pos && same_thread_group(pos, task)) in first_tid()
3877 if (nr >= get_nr_threads(task)) in first_tid()
3883 for_each_thread(task, pos) { in first_tid()
3921 struct task_struct *task; in proc_task_readdir() local
3937 for (task = first_tid(proc_pid(inode), tid, ctx->pos - 2, ns); in proc_task_readdir()
3938 task; in proc_task_readdir()
3939 task = next_tid(task), ctx->pos++) { in proc_task_readdir()
3943 tid = task_pid_nr_ns(task, ns); in proc_task_readdir()
3948 proc_task_instantiate, task, NULL)) { in proc_task_readdir()
3952 put_task_struct(task); in proc_task_readdir()