base.c (301a36fa700f9add6e14f5a95c7573e01578343a) base.c (7abbaf94049914f074306d960b0f968ffe52e59f)
1/*
2 * linux/fs/proc/base.c
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 *
6 * proc base directory handling functions
7 *
8 * 1999, Al Viro. Rewritten. Now it covers the whole per-process part.

--- 469 unchanged lines hidden (view full) ---

478 trace.entries = entries;
479 trace.skip = 0;
480
481 err = lock_trace(task);
482 if (!err) {
483 save_stack_trace_tsk(task, &trace);
484
485 for (i = 0; i < trace.nr_entries; i++) {
1/*
2 * linux/fs/proc/base.c
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 *
6 * proc base directory handling functions
7 *
8 * 1999, Al Viro. Rewritten. Now it covers the whole per-process part.

--- 469 unchanged lines hidden (view full) ---

478 trace.entries = entries;
479 trace.skip = 0;
480
481 err = lock_trace(task);
482 if (!err) {
483 save_stack_trace_tsk(task, &trace);
484
485 for (i = 0; i < trace.nr_entries; i++) {
486 seq_printf(m, "[<%pK>] %pS\n",
486 seq_printf(m, "[<%pK>] %pB\n",
487 (void *)entries[i], (void *)entries[i]);
488 }
489 unlock_trace(task);
490 }
491 kfree(entries);
492
493 return err;
494}

--- 1780 unchanged lines hidden (view full) ---

2275 err = kstrtoull_from_user(buf, count, 10, &slack_ns);
2276 if (err < 0)
2277 return err;
2278
2279 p = get_proc_task(inode);
2280 if (!p)
2281 return -ESRCH;
2282
487 (void *)entries[i], (void *)entries[i]);
488 }
489 unlock_trace(task);
490 }
491 kfree(entries);
492
493 return err;
494}

--- 1780 unchanged lines hidden (view full) ---

2275 err = kstrtoull_from_user(buf, count, 10, &slack_ns);
2276 if (err < 0)
2277 return err;
2278
2279 p = get_proc_task(inode);
2280 if (!p)
2281 return -ESRCH;
2282
2283 if (ptrace_may_access(p, PTRACE_MODE_ATTACH_FSCREDS)) {
2284 task_lock(p);
2285 if (slack_ns == 0)
2286 p->timer_slack_ns = p->default_timer_slack_ns;
2287 else
2288 p->timer_slack_ns = slack_ns;
2289 task_unlock(p);
2290 } else
2283 if (!capable(CAP_SYS_NICE)) {
2291 count = -EPERM;
2284 count = -EPERM;
2285 goto out;
2286 }
2292
2287
2288 task_lock(p);
2289 if (slack_ns == 0)
2290 p->timer_slack_ns = p->default_timer_slack_ns;
2291 else
2292 p->timer_slack_ns = slack_ns;
2293 task_unlock(p);
2294
2295out:
2293 put_task_struct(p);
2294
2295 return count;
2296}
2297
2298static int timerslack_ns_show(struct seq_file *m, void *v)
2299{
2300 struct inode *inode = m->private;
2301 struct task_struct *p;
2296 put_task_struct(p);
2297
2298 return count;
2299}
2300
2301static int timerslack_ns_show(struct seq_file *m, void *v)
2302{
2303 struct inode *inode = m->private;
2304 struct task_struct *p;
2302 int err = 0;
2305 int err = 0;
2303
2304 p = get_proc_task(inode);
2305 if (!p)
2306 return -ESRCH;
2307
2306
2307 p = get_proc_task(inode);
2308 if (!p)
2309 return -ESRCH;
2310
2308 if (ptrace_may_access(p, PTRACE_MODE_ATTACH_FSCREDS)) {
2309 task_lock(p);
2310 seq_printf(m, "%llu\n", p->timer_slack_ns);
2311 task_unlock(p);
2312 } else
2311 if (!capable(CAP_SYS_NICE)) {
2313 err = -EPERM;
2312 err = -EPERM;
2313 goto out;
2314 }
2314
2315
2316 task_lock(p);
2317 seq_printf(m, "%llu\n", p->timer_slack_ns);
2318 task_unlock(p);
2319
2320out:
2315 put_task_struct(p);
2316
2317 return err;
2318}
2319
2320static int timerslack_ns_open(struct inode *inode, struct file *filp)
2321{
2322 return single_open(filp, timerslack_ns_show, inode);

--- 1197 unchanged lines hidden ---
2321 put_task_struct(p);
2322
2323 return err;
2324}
2325
2326static int timerslack_ns_open(struct inode *inode, struct file *filp)
2327{
2328 return single_open(filp, timerslack_ns_show, inode);

--- 1197 unchanged lines hidden ---