aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sys.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sys.c')
-rw-r--r--kernel/sys.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/kernel/sys.c b/kernel/sys.c
index efcf76e0dada..123b165080e6 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -596,6 +596,7 @@ asmlinkage long sys_setpriority(int which, int who, int niceval)
596 struct task_struct *g, *p; 596 struct task_struct *g, *p;
597 struct user_struct *user; 597 struct user_struct *user;
598 int error = -EINVAL; 598 int error = -EINVAL;
599 struct pid *pgrp;
599 600
600 if (which > 2 || which < 0) 601 if (which > 2 || which < 0)
601 goto out; 602 goto out;
@@ -610,18 +611,21 @@ asmlinkage long sys_setpriority(int which, int who, int niceval)
610 read_lock(&tasklist_lock); 611 read_lock(&tasklist_lock);
611 switch (which) { 612 switch (which) {
612 case PRIO_PROCESS: 613 case PRIO_PROCESS:
613 if (!who) 614 if (who)
614 who = current->pid; 615 p = find_task_by_pid(who);
615 p = find_task_by_pid(who); 616 else
617 p = current;
616 if (p) 618 if (p)
617 error = set_one_prio(p, niceval, error); 619 error = set_one_prio(p, niceval, error);
618 break; 620 break;
619 case PRIO_PGRP: 621 case PRIO_PGRP:
620 if (!who) 622 if (who)
621 who = process_group(current); 623 pgrp = find_pid(who);
622 do_each_task_pid(who, PIDTYPE_PGID, p) { 624 else
625 pgrp = task_pgrp(current);
626 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
623 error = set_one_prio(p, niceval, error); 627 error = set_one_prio(p, niceval, error);
624 } while_each_task_pid(who, PIDTYPE_PGID, p); 628 } while_each_pid_task(pgrp, PIDTYPE_PGID, p);
625 break; 629 break;
626 case PRIO_USER: 630 case PRIO_USER:
627 user = current->user; 631 user = current->user;
@@ -656,6 +660,7 @@ asmlinkage long sys_getpriority(int which, int who)
656 struct task_struct *g, *p; 660 struct task_struct *g, *p;
657 struct user_struct *user; 661 struct user_struct *user;
658 long niceval, retval = -ESRCH; 662 long niceval, retval = -ESRCH;
663 struct pid *pgrp;
659 664
660 if (which > 2 || which < 0) 665 if (which > 2 || which < 0)
661 return -EINVAL; 666 return -EINVAL;
@@ -663,9 +668,10 @@ asmlinkage long sys_getpriority(int which, int who)
663 read_lock(&tasklist_lock); 668 read_lock(&tasklist_lock);
664 switch (which) { 669 switch (which) {
665 case PRIO_PROCESS: 670 case PRIO_PROCESS:
666 if (!who) 671 if (who)
667 who = current->pid; 672 p = find_task_by_pid(who);
668 p = find_task_by_pid(who); 673 else
674 p = current;
669 if (p) { 675 if (p) {
670 niceval = 20 - task_nice(p); 676 niceval = 20 - task_nice(p);
671 if (niceval > retval) 677 if (niceval > retval)
@@ -673,13 +679,15 @@ asmlinkage long sys_getpriority(int which, int who)
673 } 679 }
674 break; 680 break;
675 case PRIO_PGRP: 681 case PRIO_PGRP:
676 if (!who) 682 if (who)
677 who = process_group(current); 683 pgrp = find_pid(who);
678 do_each_task_pid(who, PIDTYPE_PGID, p) { 684 else
685 pgrp = task_pgrp(current);
686 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
679 niceval = 20 - task_nice(p); 687 niceval = 20 - task_nice(p);
680 if (niceval > retval) 688 if (niceval > retval)
681 retval = niceval; 689 retval = niceval;
682 } while_each_task_pid(who, PIDTYPE_PGID, p); 690 } while_each_pid_task(pgrp, PIDTYPE_PGID, p);
683 break; 691 break;
684 case PRIO_USER: 692 case PRIO_USER:
685 user = current->user; 693 user = current->user;
@@ -1388,7 +1396,7 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid)
1388 1396
1389 if (p->real_parent == group_leader) { 1397 if (p->real_parent == group_leader) {
1390 err = -EPERM; 1398 err = -EPERM;
1391 if (process_session(p) != process_session(group_leader)) 1399 if (task_session(p) != task_session(group_leader))
1392 goto out; 1400 goto out;
1393 err = -EACCES; 1401 err = -EACCES;
1394 if (p->did_exec) 1402 if (p->did_exec)
@@ -1407,7 +1415,7 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid)
1407 struct task_struct *g = 1415 struct task_struct *g =
1408 find_task_by_pid_type(PIDTYPE_PGID, pgid); 1416 find_task_by_pid_type(PIDTYPE_PGID, pgid);
1409 1417
1410 if (!g || process_session(g) != process_session(group_leader)) 1418 if (!g || task_session(g) != task_session(group_leader))
1411 goto out; 1419 goto out;
1412 } 1420 }
1413 1421