diff options
Diffstat (limited to 'kernel/sys.c')
-rw-r--r-- | kernel/sys.c | 61 |
1 files changed, 56 insertions, 5 deletions
diff --git a/kernel/sys.c b/kernel/sys.c index b3f1097c76fa..ce17760d9c51 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
@@ -14,7 +14,7 @@ | |||
14 | #include <linux/prctl.h> | 14 | #include <linux/prctl.h> |
15 | #include <linux/highuid.h> | 15 | #include <linux/highuid.h> |
16 | #include <linux/fs.h> | 16 | #include <linux/fs.h> |
17 | #include <linux/perf_counter.h> | 17 | #include <linux/perf_event.h> |
18 | #include <linux/resource.h> | 18 | #include <linux/resource.h> |
19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
20 | #include <linux/kexec.h> | 20 | #include <linux/kexec.h> |
@@ -1110,6 +1110,8 @@ SYSCALL_DEFINE0(setsid) | |||
1110 | err = session; | 1110 | err = session; |
1111 | out: | 1111 | out: |
1112 | write_unlock_irq(&tasklist_lock); | 1112 | write_unlock_irq(&tasklist_lock); |
1113 | if (err > 0) | ||
1114 | proc_sid_connector(group_leader); | ||
1113 | return err; | 1115 | return err; |
1114 | } | 1116 | } |
1115 | 1117 | ||
@@ -1338,6 +1340,7 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r) | |||
1338 | unsigned long flags; | 1340 | unsigned long flags; |
1339 | cputime_t utime, stime; | 1341 | cputime_t utime, stime; |
1340 | struct task_cputime cputime; | 1342 | struct task_cputime cputime; |
1343 | unsigned long maxrss = 0; | ||
1341 | 1344 | ||
1342 | memset((char *) r, 0, sizeof *r); | 1345 | memset((char *) r, 0, sizeof *r); |
1343 | utime = stime = cputime_zero; | 1346 | utime = stime = cputime_zero; |
@@ -1346,6 +1349,7 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r) | |||
1346 | utime = task_utime(current); | 1349 | utime = task_utime(current); |
1347 | stime = task_stime(current); | 1350 | stime = task_stime(current); |
1348 | accumulate_thread_rusage(p, r); | 1351 | accumulate_thread_rusage(p, r); |
1352 | maxrss = p->signal->maxrss; | ||
1349 | goto out; | 1353 | goto out; |
1350 | } | 1354 | } |
1351 | 1355 | ||
@@ -1363,6 +1367,7 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r) | |||
1363 | r->ru_majflt = p->signal->cmaj_flt; | 1367 | r->ru_majflt = p->signal->cmaj_flt; |
1364 | r->ru_inblock = p->signal->cinblock; | 1368 | r->ru_inblock = p->signal->cinblock; |
1365 | r->ru_oublock = p->signal->coublock; | 1369 | r->ru_oublock = p->signal->coublock; |
1370 | maxrss = p->signal->cmaxrss; | ||
1366 | 1371 | ||
1367 | if (who == RUSAGE_CHILDREN) | 1372 | if (who == RUSAGE_CHILDREN) |
1368 | break; | 1373 | break; |
@@ -1377,6 +1382,8 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r) | |||
1377 | r->ru_majflt += p->signal->maj_flt; | 1382 | r->ru_majflt += p->signal->maj_flt; |
1378 | r->ru_inblock += p->signal->inblock; | 1383 | r->ru_inblock += p->signal->inblock; |
1379 | r->ru_oublock += p->signal->oublock; | 1384 | r->ru_oublock += p->signal->oublock; |
1385 | if (maxrss < p->signal->maxrss) | ||
1386 | maxrss = p->signal->maxrss; | ||
1380 | t = p; | 1387 | t = p; |
1381 | do { | 1388 | do { |
1382 | accumulate_thread_rusage(t, r); | 1389 | accumulate_thread_rusage(t, r); |
@@ -1392,6 +1399,15 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r) | |||
1392 | out: | 1399 | out: |
1393 | cputime_to_timeval(utime, &r->ru_utime); | 1400 | cputime_to_timeval(utime, &r->ru_utime); |
1394 | cputime_to_timeval(stime, &r->ru_stime); | 1401 | cputime_to_timeval(stime, &r->ru_stime); |
1402 | |||
1403 | if (who != RUSAGE_CHILDREN) { | ||
1404 | struct mm_struct *mm = get_task_mm(p); | ||
1405 | if (mm) { | ||
1406 | setmax_mm_hiwater_rss(&maxrss, mm); | ||
1407 | mmput(mm); | ||
1408 | } | ||
1409 | } | ||
1410 | r->ru_maxrss = maxrss * (PAGE_SIZE / 1024); /* convert pages to KBs */ | ||
1395 | } | 1411 | } |
1396 | 1412 | ||
1397 | int getrusage(struct task_struct *p, int who, struct rusage __user *ru) | 1413 | int getrusage(struct task_struct *p, int who, struct rusage __user *ru) |
@@ -1511,11 +1527,11 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, | |||
1511 | case PR_SET_TSC: | 1527 | case PR_SET_TSC: |
1512 | error = SET_TSC_CTL(arg2); | 1528 | error = SET_TSC_CTL(arg2); |
1513 | break; | 1529 | break; |
1514 | case PR_TASK_PERF_COUNTERS_DISABLE: | 1530 | case PR_TASK_PERF_EVENTS_DISABLE: |
1515 | error = perf_counter_task_disable(); | 1531 | error = perf_event_task_disable(); |
1516 | break; | 1532 | break; |
1517 | case PR_TASK_PERF_COUNTERS_ENABLE: | 1533 | case PR_TASK_PERF_EVENTS_ENABLE: |
1518 | error = perf_counter_task_enable(); | 1534 | error = perf_event_task_enable(); |
1519 | break; | 1535 | break; |
1520 | case PR_GET_TIMERSLACK: | 1536 | case PR_GET_TIMERSLACK: |
1521 | error = current->timer_slack_ns; | 1537 | error = current->timer_slack_ns; |
@@ -1528,6 +1544,41 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, | |||
1528 | current->timer_slack_ns = arg2; | 1544 | current->timer_slack_ns = arg2; |
1529 | error = 0; | 1545 | error = 0; |
1530 | break; | 1546 | break; |
1547 | case PR_MCE_KILL: | ||
1548 | if (arg4 | arg5) | ||
1549 | return -EINVAL; | ||
1550 | switch (arg2) { | ||
1551 | case PR_MCE_KILL_CLEAR: | ||
1552 | if (arg3 != 0) | ||
1553 | return -EINVAL; | ||
1554 | current->flags &= ~PF_MCE_PROCESS; | ||
1555 | break; | ||
1556 | case PR_MCE_KILL_SET: | ||
1557 | current->flags |= PF_MCE_PROCESS; | ||
1558 | if (arg3 == PR_MCE_KILL_EARLY) | ||
1559 | current->flags |= PF_MCE_EARLY; | ||
1560 | else if (arg3 == PR_MCE_KILL_LATE) | ||
1561 | current->flags &= ~PF_MCE_EARLY; | ||
1562 | else if (arg3 == PR_MCE_KILL_DEFAULT) | ||
1563 | current->flags &= | ||
1564 | ~(PF_MCE_EARLY|PF_MCE_PROCESS); | ||
1565 | else | ||
1566 | return -EINVAL; | ||
1567 | break; | ||
1568 | default: | ||
1569 | return -EINVAL; | ||
1570 | } | ||
1571 | error = 0; | ||
1572 | break; | ||
1573 | case PR_MCE_KILL_GET: | ||
1574 | if (arg2 | arg3 | arg4 | arg5) | ||
1575 | return -EINVAL; | ||
1576 | if (current->flags & PF_MCE_PROCESS) | ||
1577 | error = (current->flags & PF_MCE_EARLY) ? | ||
1578 | PR_MCE_KILL_EARLY : PR_MCE_KILL_LATE; | ||
1579 | else | ||
1580 | error = PR_MCE_KILL_DEFAULT; | ||
1581 | break; | ||
1531 | default: | 1582 | default: |
1532 | error = -EINVAL; | 1583 | error = -EINVAL; |
1533 | break; | 1584 | break; |