diff options
Diffstat (limited to 'fs/proc/base.c')
-rw-r--r-- | fs/proc/base.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index 3b792ab3c0dc..248f008d46b8 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -2280,16 +2280,19 @@ static ssize_t timerslack_ns_write(struct file *file, const char __user *buf, | |||
2280 | if (!p) | 2280 | if (!p) |
2281 | return -ESRCH; | 2281 | return -ESRCH; |
2282 | 2282 | ||
2283 | if (ptrace_may_access(p, PTRACE_MODE_ATTACH_FSCREDS)) { | 2283 | if (!capable(CAP_SYS_NICE)) { |
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 | ||
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 | |||
2295 | out: | ||
2293 | put_task_struct(p); | 2296 | put_task_struct(p); |
2294 | 2297 | ||
2295 | return count; | 2298 | return count; |
@@ -2299,19 +2302,22 @@ static int timerslack_ns_show(struct seq_file *m, void *v) | |||
2299 | { | 2302 | { |
2300 | struct inode *inode = m->private; | 2303 | struct inode *inode = m->private; |
2301 | struct task_struct *p; | 2304 | struct task_struct *p; |
2302 | int err = 0; | 2305 | int err = 0; |
2303 | 2306 | ||
2304 | p = get_proc_task(inode); | 2307 | p = get_proc_task(inode); |
2305 | if (!p) | 2308 | if (!p) |
2306 | return -ESRCH; | 2309 | return -ESRCH; |
2307 | 2310 | ||
2308 | if (ptrace_may_access(p, PTRACE_MODE_ATTACH_FSCREDS)) { | 2311 | if (!capable(CAP_SYS_NICE)) { |
2309 | task_lock(p); | ||
2310 | seq_printf(m, "%llu\n", p->timer_slack_ns); | ||
2311 | task_unlock(p); | ||
2312 | } else | ||
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 | |||
2320 | out: | ||
2315 | put_task_struct(p); | 2321 | put_task_struct(p); |
2316 | 2322 | ||
2317 | return err; | 2323 | return err; |