Lines Matching refs:task
173 static int get_task_root(struct task_struct *task, struct path *root) in get_task_root() argument
177 task_lock(task); in get_task_root()
178 if (task->fs) { in get_task_root()
179 get_fs_root(task->fs, root); in get_task_root()
182 task_unlock(task); in get_task_root()
188 struct task_struct *task = get_proc_task(d_inode(dentry)); in proc_cwd_link() local
191 if (task) { in proc_cwd_link()
192 task_lock(task); in proc_cwd_link()
193 if (task->fs) { in proc_cwd_link()
194 get_fs_pwd(task->fs, path); in proc_cwd_link()
197 task_unlock(task); in proc_cwd_link()
198 put_task_struct(task); in proc_cwd_link()
205 struct task_struct *task = get_proc_task(d_inode(dentry)); in proc_root_link() local
208 if (task) { in proc_root_link()
209 result = get_task_root(task, path); in proc_root_link()
210 put_task_struct(task); in proc_root_link()
387 struct pid *pid, struct task_struct *task) in proc_pid_wchan() argument
392 if (!ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS)) in proc_pid_wchan()
395 wchan = get_wchan(task); in proc_pid_wchan()
407 static int lock_trace(struct task_struct *task) in lock_trace() argument
409 int err = down_read_killable(&task->signal->exec_update_lock); in lock_trace()
412 if (!ptrace_may_access(task, PTRACE_MODE_ATTACH_FSCREDS)) { in lock_trace()
413 up_read(&task->signal->exec_update_lock); in lock_trace()
419 static void unlock_trace(struct task_struct *task) in unlock_trace() argument
421 up_read(&task->signal->exec_update_lock); in unlock_trace()
429 struct pid *pid, struct task_struct *task) in proc_pid_stack() argument
453 err = lock_trace(task); in proc_pid_stack()
457 nr_entries = stack_trace_save_tsk(task, entries, in proc_pid_stack()
464 unlock_trace(task); in proc_pid_stack()
477 struct pid *pid, struct task_struct *task) in proc_pid_schedstat() argument
483 (unsigned long long)task->se.sum_exec_runtime, in proc_pid_schedstat()
484 (unsigned long long)task->sched_info.run_delay, in proc_pid_schedstat()
485 task->sched_info.pcount); in proc_pid_schedstat()
496 struct task_struct *task = get_proc_task(inode); in lstats_show_proc() local
498 if (!task) in lstats_show_proc()
502 struct latency_record *lr = &task->latency_record[i]; in lstats_show_proc()
518 put_task_struct(task); in lstats_show_proc()
530 struct task_struct *task = get_proc_task(file_inode(file)); in lstats_write() local
532 if (!task) in lstats_write()
534 clear_tsk_latency_tracing(task); in lstats_write()
535 put_task_struct(task); in lstats_write()
551 struct pid *pid, struct task_struct *task) in proc_oom_score() argument
557 badness = oom_badness(task, totalpages); in proc_oom_score()
597 struct pid *pid, struct task_struct *task) in proc_pid_limits() argument
604 if (!lock_task_sighand(task, &flags)) in proc_pid_limits()
606 memcpy(rlim, task->signal->rlim, sizeof(struct rlimit) * RLIM_NLIMITS); in proc_pid_limits()
607 unlock_task_sighand(task, &flags); in proc_pid_limits()
641 struct pid *pid, struct task_struct *task) in proc_pid_syscall() argument
647 res = lock_trace(task); in proc_pid_syscall()
651 if (task_current_syscall(task, &info)) in proc_pid_syscall()
662 unlock_trace(task); in proc_pid_syscall()
675 struct task_struct *task; in proc_fd_access_allowed() local
681 task = get_proc_task(inode); in proc_fd_access_allowed()
682 if (task) { in proc_fd_access_allowed()
683 allowed = ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS); in proc_fd_access_allowed()
684 put_task_struct(task); in proc_fd_access_allowed()
712 struct task_struct *task, in has_pid_permissions() argument
721 return ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS); in has_pid_permissions()
727 return ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS); in has_pid_permissions()
735 struct task_struct *task; in proc_pid_permission() local
738 task = get_proc_task(inode); in proc_pid_permission()
739 if (!task) in proc_pid_permission()
741 has_perms = has_pid_permissions(fs_info, task, HIDEPID_NO_ACCESS); in proc_pid_permission()
742 put_task_struct(task); in proc_pid_permission()
771 struct task_struct *task; in proc_single_show() local
774 task = get_pid_task(pid, PIDTYPE_PID); in proc_single_show()
775 if (!task) in proc_single_show()
778 ret = PROC_I(inode)->op.proc_show(m, ns, pid, task); in proc_single_show()
780 put_task_struct(task); in proc_single_show()
799 struct task_struct *task = get_proc_task(inode); in proc_mem_open() local
802 if (task) { in proc_mem_open()
803 mm = mm_access(task, mode | PTRACE_MODE_FSCREDS); in proc_mem_open()
804 put_task_struct(task); in proc_mem_open()
1042 struct task_struct *task = get_proc_task(file_inode(file)); in oom_adj_read() local
1047 if (!task) in oom_adj_read()
1049 if (task->signal->oom_score_adj == OOM_SCORE_ADJ_MAX) in oom_adj_read()
1052 oom_adj = (task->signal->oom_score_adj * -OOM_DISABLE) / in oom_adj_read()
1054 put_task_struct(task); in oom_adj_read()
1064 struct task_struct *task; in __set_oom_adj() local
1067 task = get_proc_task(file_inode(file)); in __set_oom_adj()
1068 if (!task) in __set_oom_adj()
1073 if (oom_adj < task->signal->oom_score_adj && in __set_oom_adj()
1083 current->comm, task_pid_nr(current), task_pid_nr(task), in __set_oom_adj()
1084 task_pid_nr(task)); in __set_oom_adj()
1086 if ((short)oom_adj < task->signal->oom_score_adj_min && in __set_oom_adj()
1098 if (!task->vfork_done) { in __set_oom_adj()
1099 struct task_struct *p = find_lock_task_mm(task); in __set_oom_adj()
1110 task->signal->oom_score_adj = oom_adj; in __set_oom_adj()
1112 task->signal->oom_score_adj_min = (short)oom_adj; in __set_oom_adj()
1113 trace_oom_score_adj_update(task); in __set_oom_adj()
1120 if (same_thread_group(task, p)) in __set_oom_adj()
1140 put_task_struct(task); in __set_oom_adj()
1201 struct task_struct *task = get_proc_task(file_inode(file)); in oom_score_adj_read() local
1206 if (!task) in oom_score_adj_read()
1208 oom_score_adj = task->signal->oom_score_adj; in oom_score_adj_read()
1209 put_task_struct(task); in oom_score_adj_read()
1255 struct task_struct *task = get_proc_task(inode); in proc_loginuid_read() local
1259 if (!task) in proc_loginuid_read()
1263 audit_get_loginuid(task))); in proc_loginuid_read()
1264 put_task_struct(task); in proc_loginuid_read()
1321 struct task_struct *task = get_proc_task(inode); in proc_sessionid_read() local
1325 if (!task) in proc_sessionid_read()
1328 audit_get_sessionid(task)); in proc_sessionid_read()
1329 put_task_struct(task); in proc_sessionid_read()
1343 struct task_struct *task = get_proc_task(file_inode(file)); in proc_fault_inject_read() local
1348 if (!task) in proc_fault_inject_read()
1350 make_it_fail = task->make_it_fail; in proc_fault_inject_read()
1351 put_task_struct(task); in proc_fault_inject_read()
1361 struct task_struct *task; in proc_fault_inject_write() local
1379 task = get_proc_task(file_inode(file)); in proc_fault_inject_write()
1380 if (!task) in proc_fault_inject_write()
1382 task->make_it_fail = make_it_fail; in proc_fault_inject_write()
1383 put_task_struct(task); in proc_fault_inject_write()
1397 struct task_struct *task; in proc_fail_nth_write() local
1405 task = get_proc_task(file_inode(file)); in proc_fail_nth_write()
1406 if (!task) in proc_fail_nth_write()
1408 task->fail_nth = n; in proc_fail_nth_write()
1409 put_task_struct(task); in proc_fail_nth_write()
1417 struct task_struct *task; in proc_fail_nth_read() local
1421 task = get_proc_task(file_inode(file)); in proc_fail_nth_read()
1422 if (!task) in proc_fail_nth_read()
1424 len = snprintf(numbuf, sizeof(numbuf), "%u\n", task->fail_nth); in proc_fail_nth_read()
1425 put_task_struct(task); in proc_fail_nth_read()
1725 struct task_struct *task; in proc_exe_link() local
1728 task = get_proc_task(d_inode(dentry)); in proc_exe_link()
1729 if (!task) in proc_exe_link()
1731 exe_file = get_task_exe_file(task); in proc_exe_link()
1732 put_task_struct(task); in proc_exe_link()
1818 void task_dump_owner(struct task_struct *task, umode_t mode, in task_dump_owner() argument
1828 if (unlikely(task->flags & PF_KTHREAD)) { in task_dump_owner()
1836 cred = __task_cred(task); in task_dump_owner()
1851 task_lock(task); in task_dump_owner()
1852 mm = task->mm; in task_dump_owner()
1870 task_unlock(task); in task_dump_owner()
1890 struct task_struct *task, umode_t mode) in proc_pid_make_inode() argument
1912 pid = get_task_pid(task, PIDTYPE_PID); in proc_pid_make_inode()
1924 task_dump_owner(task, 0, &inode->i_uid, &inode->i_gid); in proc_pid_make_inode()
1925 security_task_to_inode(task, inode); in proc_pid_make_inode()
1940 struct task_struct *task; in pid_getattr() local
1947 task = pid_task(proc_pid(inode), PIDTYPE_PID); in pid_getattr()
1948 if (task) { in pid_getattr()
1949 if (!has_pid_permissions(fs_info, task, HIDEPID_INVISIBLE)) { in pid_getattr()
1957 task_dump_owner(task, inode->i_mode, &stat->uid, &stat->gid); in pid_getattr()
1968 void pid_update_inode(struct task_struct *task, struct inode *inode) in pid_update_inode() argument
1970 task_dump_owner(task, inode->i_mode, &inode->i_uid, &inode->i_gid); in pid_update_inode()
1973 security_task_to_inode(task, inode); in pid_update_inode()
1984 struct task_struct *task; in pid_revalidate() local
1991 task = pid_task(proc_pid(inode), PIDTYPE_PID); in pid_revalidate()
1993 if (task) { in pid_revalidate()
1994 pid_update_inode(task, inode); in pid_revalidate()
2038 instantiate_t instantiate, struct task_struct *task, const void *ptr) in proc_fill_cache() argument
2054 res = instantiate(child, task, ptr); in proc_fill_cache()
2119 struct task_struct *task; in map_files_d_revalidate() local
2127 task = get_proc_task(inode); in map_files_d_revalidate()
2128 if (!task) in map_files_d_revalidate()
2131 mm = mm_access(task, PTRACE_MODE_READ_FSCREDS); in map_files_d_revalidate()
2147 task_dump_owner(task, 0, &inode->i_uid, &inode->i_gid); in map_files_d_revalidate()
2149 security_task_to_inode(task, inode); in map_files_d_revalidate()
2154 put_task_struct(task); in map_files_d_revalidate()
2169 struct task_struct *task; in map_files_get_link() local
2174 task = get_proc_task(d_inode(dentry)); in map_files_get_link()
2175 if (!task) in map_files_get_link()
2178 mm = get_task_mm(task); in map_files_get_link()
2179 put_task_struct(task); in map_files_get_link()
2239 struct task_struct *task, const void *ptr) in proc_map_files_instantiate() argument
2245 inode = proc_pid_make_inode(dentry->d_sb, task, S_IFLNK | in proc_map_files_instantiate()
2266 struct task_struct *task; in proc_map_files_lookup() local
2271 task = get_proc_task(dir); in proc_map_files_lookup()
2272 if (!task) in proc_map_files_lookup()
2276 if (!ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS)) in proc_map_files_lookup()
2283 mm = get_task_mm(task); in proc_map_files_lookup()
2297 result = proc_map_files_instantiate(dentry, task, in proc_map_files_lookup()
2305 put_task_struct(task); in proc_map_files_lookup()
2320 struct task_struct *task; in proc_map_files_readdir() local
2330 task = get_proc_task(file_inode(file)); in proc_map_files_readdir()
2331 if (!task) in proc_map_files_readdir()
2335 if (!ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS)) in proc_map_files_readdir()
2342 mm = get_task_mm(task); in proc_map_files_readdir()
2394 task, in proc_map_files_readdir()
2401 put_task_struct(task); in proc_map_files_readdir()
2416 struct task_struct *task; member
2426 tp->task = get_pid_task(tp->pid, PIDTYPE_PID); in timers_start()
2427 if (!tp->task) in timers_start()
2430 tp->sighand = lock_task_sighand(tp->task, &tp->flags); in timers_start()
2434 return seq_list_start(&tp->task->signal->posix_timers, *pos); in timers_start()
2440 return seq_list_next(v, &tp->task->signal->posix_timers, pos); in timers_next()
2448 unlock_task_sighand(tp->task, &tp->flags); in timers_stop()
2452 if (tp->task) { in timers_stop()
2453 put_task_struct(tp->task); in timers_stop()
2454 tp->task = NULL; in timers_stop()
2607 struct task_struct *task, const void *ptr) in proc_pident_instantiate() argument
2613 inode = proc_pid_make_inode(dentry->d_sb, task, p->mode); in proc_pident_instantiate()
2625 pid_update_inode(task, inode); in proc_pident_instantiate()
2635 struct task_struct *task = get_proc_task(dir); in proc_pident_lookup() local
2638 if (!task) in proc_pident_lookup()
2649 res = proc_pident_instantiate(dentry, task, p); in proc_pident_lookup()
2653 put_task_struct(task); in proc_pident_lookup()
2661 struct task_struct *task = get_proc_task(file_inode(file)); in proc_pident_readdir() local
2664 if (!task) in proc_pident_readdir()
2675 proc_pident_instantiate, task, p)) in proc_pident_readdir()
2680 put_task_struct(task); in proc_pident_readdir()
2698 struct task_struct *task = get_proc_task(inode); in proc_pid_attr_read() local
2700 if (!task) in proc_pid_attr_read()
2703 length = security_getprocattr(task, PROC_I(inode)->op.lsm, in proc_pid_attr_read()
2706 put_task_struct(task); in proc_pid_attr_read()
2717 struct task_struct *task; in proc_pid_attr_write() local
2726 task = pid_task(proc_pid(inode), PIDTYPE_PID); in proc_pid_attr_write()
2727 if (!task) { in proc_pid_attr_write()
2732 if (current != task) { in proc_pid_attr_write()
2873 struct task_struct *task = get_proc_task(file_inode(file)); in proc_coredump_filter_read() local
2879 if (!task) in proc_coredump_filter_read()
2883 mm = get_task_mm(task); in proc_coredump_filter_read()
2892 put_task_struct(task); in proc_coredump_filter_read()
2902 struct task_struct *task; in proc_coredump_filter_write() local
2914 task = get_proc_task(file_inode(file)); in proc_coredump_filter_write()
2915 if (!task) in proc_coredump_filter_write()
2918 mm = get_task_mm(task); in proc_coredump_filter_write()
2932 put_task_struct(task); in proc_coredump_filter_write()
2947 static int do_io_accounting(struct task_struct *task, struct seq_file *m, int whole) in do_io_accounting() argument
2949 struct task_io_accounting acct = task->ioac; in do_io_accounting()
2953 result = down_read_killable(&task->signal->exec_update_lock); in do_io_accounting()
2957 if (!ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS)) { in do_io_accounting()
2962 if (whole && lock_task_sighand(task, &flags)) { in do_io_accounting()
2963 struct task_struct *t = task; in do_io_accounting()
2965 task_io_accounting_add(&acct, &task->signal->ioac); in do_io_accounting()
2966 while_each_thread(task, t) in do_io_accounting()
2969 unlock_task_sighand(task, &flags); in do_io_accounting()
2989 up_read(&task->signal->exec_update_lock); in do_io_accounting()
2994 struct pid *pid, struct task_struct *task) in proc_tid_io_accounting() argument
2996 return do_io_accounting(task, m, 0); in proc_tid_io_accounting()
3000 struct pid *pid, struct task_struct *task) in proc_tgid_io_accounting() argument
3002 return do_io_accounting(task, m, 1); in proc_tgid_io_accounting()
3011 struct task_struct *task; in proc_id_map_open() local
3015 task = get_proc_task(inode); in proc_id_map_open()
3016 if (task) { in proc_id_map_open()
3018 ns = get_user_ns(task_cred_xxx(task, user_ns)); in proc_id_map_open()
3020 put_task_struct(task); in proc_id_map_open()
3089 struct task_struct *task; in proc_setgroups_open() local
3093 task = get_proc_task(inode); in proc_setgroups_open()
3094 if (task) { in proc_setgroups_open()
3096 ns = get_user_ns(task_cred_xxx(task, user_ns)); in proc_setgroups_open()
3098 put_task_struct(task); in proc_setgroups_open()
3139 struct pid *pid, struct task_struct *task) in proc_pid_personality() argument
3141 int err = lock_trace(task); in proc_pid_personality()
3143 seq_printf(m, "%08x\n", task->personality); in proc_pid_personality()
3144 unlock_trace(task); in proc_pid_personality()
3151 struct pid *pid, struct task_struct *task) in proc_pid_patch_state() argument
3153 seq_printf(m, "%d\n", task->patch_state); in proc_pid_patch_state()
3160 struct pid *pid, struct task_struct *task) in proc_stack_depth() argument
3163 (task->prev_lowest_stack & (THREAD_SIZE - 1)); in proc_stack_depth()
3165 (task->lowest_stack & (THREAD_SIZE - 1)); in proc_stack_depth()
3350 struct task_struct *task, const void *ptr) in proc_pid_instantiate() argument
3354 inode = proc_pid_make_inode(dentry->d_sb, task, S_IFDIR | S_IRUGO | S_IXUGO); in proc_pid_instantiate()
3363 pid_update_inode(task, inode); in proc_pid_instantiate()
3371 struct task_struct *task; in proc_pid_lookup() local
3384 task = find_task_by_pid_ns(tgid, ns); in proc_pid_lookup()
3385 if (task) in proc_pid_lookup()
3386 get_task_struct(task); in proc_pid_lookup()
3388 if (!task) in proc_pid_lookup()
3393 if (!has_pid_permissions(fs_info, task, HIDEPID_NO_ACCESS)) in proc_pid_lookup()
3397 result = proc_pid_instantiate(dentry, task, NULL); in proc_pid_lookup()
3399 put_task_struct(task); in proc_pid_lookup()
3410 struct task_struct *task; member
3416 if (iter.task) in next_tgid()
3417 put_task_struct(iter.task); in next_tgid()
3420 iter.task = NULL; in next_tgid()
3424 iter.task = pid_task(pid, PIDTYPE_TGID); in next_tgid()
3425 if (!iter.task) { in next_tgid()
3429 get_task_struct(iter.task); in next_tgid()
3461 iter.task = NULL; in proc_pid_readdir()
3463 iter.task; in proc_pid_readdir()
3469 if (!has_pid_permissions(fs_info, iter.task, HIDEPID_INVISIBLE)) in proc_pid_readdir()
3475 proc_pid_instantiate, iter.task, NULL)) { in proc_pid_readdir()
3476 put_task_struct(iter.task); in proc_pid_readdir()
3500 struct task_struct *task; in proc_tid_comm_permission() local
3502 task = get_proc_task(inode); in proc_tid_comm_permission()
3503 if (!task) in proc_tid_comm_permission()
3505 is_same_tgroup = same_thread_group(current, task); in proc_tid_comm_permission()
3506 put_task_struct(task); in proc_tid_comm_permission()
3650 struct task_struct *task, const void *ptr) in proc_task_instantiate() argument
3653 inode = proc_pid_make_inode(dentry->d_sb, task, S_IFDIR | S_IRUGO | S_IXUGO); in proc_task_instantiate()
3662 pid_update_inode(task, inode); in proc_task_instantiate()
3670 struct task_struct *task; in proc_task_lookup() local
3687 task = find_task_by_pid_ns(tid, ns); in proc_task_lookup()
3688 if (task) in proc_task_lookup()
3689 get_task_struct(task); in proc_task_lookup()
3691 if (!task) in proc_task_lookup()
3693 if (!same_thread_group(leader, task)) in proc_task_lookup()
3696 result = proc_task_instantiate(dentry, task, NULL); in proc_task_lookup()
3698 put_task_struct(task); in proc_task_lookup()
3720 struct task_struct *pos, *task; in first_tid() local
3727 task = pid_task(pid, PIDTYPE_PID); in first_tid()
3728 if (!task) in first_tid()
3734 if (pos && same_thread_group(pos, task)) in first_tid()
3739 if (nr >= get_nr_threads(task)) in first_tid()
3745 pos = task = task->group_leader; in first_tid()
3749 } while_each_thread(task, pos); in first_tid()
3786 struct task_struct *task; in proc_task_readdir() local
3802 for (task = first_tid(proc_pid(inode), tid, ctx->pos - 2, ns); in proc_task_readdir()
3803 task; in proc_task_readdir()
3804 task = next_tid(task), ctx->pos++) { in proc_task_readdir()
3808 tid = task_pid_nr_ns(task, ns); in proc_task_readdir()
3813 proc_task_instantiate, task, NULL)) { in proc_task_readdir()
3817 put_task_struct(task); in proc_task_readdir()