4 * Copyright (C) 1991, 1992 Linus Torvalds
8 #include <linux/utsname.h>
9 #include <linux/mman.h>
10 #include <linux/smp_lock.h>
11 #include <linux/notifier.h>
12 #include <linux/reboot.h>
13 #include <linux/prctl.h>
14 #include <linux/init.h>
16 #include <asm/uaccess.h>
20 * this indicates whether you can reboot with ctrl-alt-del: the default is yes
27 * Notifier list for kernel code which wants to be called
28 * at shutdown. This is used to stop any idling DMA operations
32 struct notifier_block
*reboot_notifier_list
= NULL
;
34 int register_reboot_notifier(struct notifier_block
* nb
)
36 return notifier_chain_register(&reboot_notifier_list
, nb
);
39 int unregister_reboot_notifier(struct notifier_block
* nb
)
41 return notifier_chain_unregister(&reboot_notifier_list
, nb
);
44 asmlinkage
long sys_ni_syscall(void)
49 static int proc_sel(struct task_struct
*p
, int which
, int who
)
55 if (!who
&& p
== current
)
57 return(p
->pid
== who
);
61 return(p
->pgrp
== who
);
65 return(p
->uid
== who
);
71 asmlinkage
long sys_setpriority(int which
, int who
, int niceval
)
73 struct task_struct
*p
;
74 unsigned int priority
;
77 if (which
> 2 || which
< 0)
80 /* normalize: avoid signed division (rounding problems) */
87 priority
= (priority
* DEF_PRIORITY
+ 10) / 20 + DEF_PRIORITY
;
90 priority
= 2*DEF_PRIORITY
- priority
;
95 read_lock(&tasklist_lock
);
97 if (!proc_sel(p
, which
, who
))
99 if (p
->uid
!= current
->euid
&&
100 p
->uid
!= current
->uid
&& !capable(CAP_SYS_NICE
)) {
106 if (priority
> p
->priority
&& !capable(CAP_SYS_NICE
))
109 p
->priority
= priority
;
111 read_unlock(&tasklist_lock
);
117 * Ugh. To avoid negative return values, "getpriority()" will
118 * not return the normal nice-value, but a value that has been
119 * offset by 20 (ie it returns 0..40 instead of -20..20)
121 asmlinkage
long sys_getpriority(int which
, int who
)
123 struct task_struct
*p
;
124 long max_prio
= -ESRCH
;
126 if (which
> 2 || which
< 0)
129 read_lock(&tasklist_lock
);
131 if (!proc_sel(p
, which
, who
))
133 if (p
->priority
> max_prio
)
134 max_prio
= p
->priority
;
136 read_unlock(&tasklist_lock
);
138 /* scale the priority from timeslice to 0..40 */
140 max_prio
= (max_prio
* 20 + DEF_PRIORITY
/2) / DEF_PRIORITY
;
146 * Reboot system call: for obvious reasons only root may call it,
147 * and even root needs to set up some magic numbers in the registers
148 * so that some mistake won't make this reboot the whole machine.
149 * You can also set the meaning of the ctrl-alt-del-key here.
151 * reboot doesn't sync: do that yourself before calling this.
153 asmlinkage
long sys_reboot(int magic1
, int magic2
, int cmd
, void * arg
)
157 /* We only trust the superuser with rebooting the system. */
158 if (!capable(CAP_SYS_BOOT
))
161 /* For safety, we require "magic" arguments. */
162 if (magic1
!= LINUX_REBOOT_MAGIC1
||
163 (magic2
!= LINUX_REBOOT_MAGIC2
&& magic2
!= LINUX_REBOOT_MAGIC2A
&&
164 magic2
!= LINUX_REBOOT_MAGIC2B
))
169 case LINUX_REBOOT_CMD_RESTART
:
170 notifier_call_chain(&reboot_notifier_list
, SYS_RESTART
, NULL
);
171 printk(KERN_EMERG
"Restarting system.\n");
172 machine_restart(NULL
);
175 case LINUX_REBOOT_CMD_CAD_ON
:
179 case LINUX_REBOOT_CMD_CAD_OFF
:
183 case LINUX_REBOOT_CMD_HALT
:
184 notifier_call_chain(&reboot_notifier_list
, SYS_HALT
, NULL
);
185 printk(KERN_EMERG
"System halted.\n");
190 case LINUX_REBOOT_CMD_POWER_OFF
:
191 notifier_call_chain(&reboot_notifier_list
, SYS_POWER_OFF
, NULL
);
192 printk(KERN_EMERG
"Power down.\n");
197 case LINUX_REBOOT_CMD_RESTART2
:
198 if (strncpy_from_user(&buffer
[0], (char *)arg
, sizeof(buffer
) - 1) < 0) {
202 buffer
[sizeof(buffer
) - 1] = '\0';
204 notifier_call_chain(&reboot_notifier_list
, SYS_RESTART
, buffer
);
205 printk(KERN_EMERG
"Restarting system with command '%s'.\n", buffer
);
206 machine_restart(buffer
);
219 * This function gets called by ctrl-alt-del - ie the keyboard interrupt.
220 * As it's called within an interrupt, it may NOT sync: the only choice
221 * is whether to reboot at once, or just ignore the ctrl-alt-del.
223 void ctrl_alt_del(void)
226 notifier_call_chain(&reboot_notifier_list
, SYS_RESTART
, NULL
);
227 machine_restart(NULL
);
229 kill_proc(1, SIGINT
, 1);
234 * Unprivileged users may change the real gid to the effective gid
235 * or vice versa. (BSD-style)
237 * If you set the real gid at all, or set the effective gid to a value not
238 * equal to the real gid, then the saved gid is set to the new effective gid.
240 * This makes it possible for a setgid program to completely drop its
241 * privileges, which is often a useful assertion to make when you are doing
242 * a security audit over a program.
244 * The general idea is that a program which uses just setregid() will be
245 * 100% compatible with BSD. A program which uses just setgid() will be
246 * 100% compatible with POSIX with saved IDs.
248 * SMP: There are not races, the GIDs are checked only by filesystem
249 * operations (as far as semantic preservation is concerned).
251 asmlinkage
long sys_setregid(gid_t rgid
, gid_t egid
)
253 int old_rgid
= current
->gid
;
254 int old_egid
= current
->egid
;
256 if (rgid
!= (gid_t
) -1) {
257 if ((old_rgid
== rgid
) ||
258 (current
->egid
==rgid
) ||
264 if (egid
!= (gid_t
) -1) {
265 if ((old_rgid
== egid
) ||
266 (current
->egid
== egid
) ||
267 (current
->sgid
== egid
) ||
269 current
->fsgid
= current
->egid
= egid
;
271 current
->gid
= old_rgid
;
275 if (rgid
!= (gid_t
) -1 ||
276 (egid
!= (gid_t
) -1 && egid
!= old_rgid
))
277 current
->sgid
= current
->egid
;
278 current
->fsgid
= current
->egid
;
279 if (current
->egid
!= old_egid
)
280 current
->dumpable
= 0;
285 * setgid() is implemented like SysV w/ SAVED_IDS
287 * SMP: Same implicit races as above.
289 asmlinkage
long sys_setgid(gid_t gid
)
291 int old_egid
= current
->egid
;
293 if (capable(CAP_SETGID
))
294 current
->gid
= current
->egid
= current
->sgid
= current
->fsgid
= gid
;
295 else if ((gid
== current
->gid
) || (gid
== current
->sgid
))
296 current
->egid
= current
->fsgid
= gid
;
300 if (current
->egid
!= old_egid
)
301 current
->dumpable
= 0;
306 * cap_emulate_setxuid() fixes the effective / permitted capabilities of
307 * a process after a call to setuid, setreuid, or setresuid.
309 * 1) When set*uiding _from_ one of {r,e,s}uid == 0 _to_ all of
310 * {r,e,s}uid != 0, the permitted and effective capabilities are
313 * 2) When set*uiding _from_ euid == 0 _to_ euid != 0, the effective
314 * capabilities of the process are cleared.
316 * 3) When set*uiding _from_ euid != 0 _to_ euid == 0, the effective
317 * capabilities are set to the permitted capabilities.
319 * fsuid is handled elsewhere. fsuid == 0 and {r,e,s}uid!= 0 should
324 extern inline void cap_emulate_setxuid(int old_ruid
, int old_euid
,
327 if ((old_ruid
== 0 || old_euid
== 0 || old_suid
== 0) &&
328 (current
->uid
!= 0 && current
->euid
!= 0 && current
->suid
!= 0)) {
329 cap_clear(current
->cap_permitted
);
330 cap_clear(current
->cap_effective
);
332 if (old_euid
== 0 && current
->euid
!= 0) {
333 cap_clear(current
->cap_effective
);
335 if (old_euid
!= 0 && current
->euid
== 0) {
336 current
->cap_effective
= current
->cap_permitted
;
341 * Unprivileged users may change the real uid to the effective uid
342 * or vice versa. (BSD-style)
344 * If you set the real uid at all, or set the effective uid to a value not
345 * equal to the real uid, then the saved uid is set to the new effective uid.
347 * This makes it possible for a setuid program to completely drop its
348 * privileges, which is often a useful assertion to make when you are doing
349 * a security audit over a program.
351 * The general idea is that a program which uses just setreuid() will be
352 * 100% compatible with BSD. A program which uses just setuid() will be
353 * 100% compatible with POSIX with saved IDs.
355 asmlinkage
long sys_setreuid(uid_t ruid
, uid_t euid
)
357 int old_ruid
, old_euid
, old_suid
, new_ruid
;
359 new_ruid
= old_ruid
= current
->uid
;
360 old_euid
= current
->euid
;
361 old_suid
= current
->suid
;
362 if (ruid
!= (uid_t
) -1) {
363 if ((old_ruid
== ruid
) ||
364 (current
->euid
==ruid
) ||
370 if (euid
!= (uid_t
) -1) {
371 if ((old_ruid
== euid
) ||
372 (current
->euid
== euid
) ||
373 (current
->suid
== euid
) ||
375 current
->fsuid
= current
->euid
= euid
;
379 if (ruid
!= (uid_t
) -1 ||
380 (euid
!= (uid_t
) -1 && euid
!= old_ruid
))
381 current
->suid
= current
->euid
;
382 current
->fsuid
= current
->euid
;
383 if (current
->euid
!= old_euid
)
384 current
->dumpable
= 0;
386 if(new_ruid
!= old_ruid
) {
387 /* What if a process setreuid()'s and this brings the
388 * new uid over his NPROC rlimit? We can check this now
389 * cheaply with the new uid cache, so if it matters
390 * we should be checking for it. -DaveM
393 current
->uid
= new_ruid
;
397 if (!issecure(SECURE_NO_SETUID_FIXUP
)) {
398 cap_emulate_setxuid(old_ruid
, old_euid
, old_suid
);
407 * setuid() is implemented like SysV with SAVED_IDS
409 * Note that SAVED_ID's is deficient in that a setuid root program
410 * like sendmail, for example, cannot set its uid to be a normal
411 * user and then switch back, because if you're root, setuid() sets
412 * the saved uid too. If you don't like this, blame the bright people
413 * in the POSIX committee and/or USG. Note that the BSD-style setreuid()
414 * will allow a root program to temporarily drop privileges and be able to
415 * regain them by swapping the real and effective uid.
417 asmlinkage
long sys_setuid(uid_t uid
)
419 int old_euid
= current
->euid
;
420 int old_ruid
, old_suid
, new_ruid
;
422 old_ruid
= new_ruid
= current
->uid
;
423 old_suid
= current
->suid
;
424 if (capable(CAP_SETUID
))
425 new_ruid
= current
->euid
= current
->suid
= current
->fsuid
= uid
;
426 else if ((uid
== current
->uid
) || (uid
== current
->suid
))
427 current
->fsuid
= current
->euid
= uid
;
431 if (current
->euid
!= old_euid
)
432 current
->dumpable
= 0;
434 if (new_ruid
!= old_ruid
) {
435 /* See comment above about NPROC rlimit issues... */
437 current
->uid
= new_ruid
;
441 if (!issecure(SECURE_NO_SETUID_FIXUP
)) {
442 cap_emulate_setxuid(old_ruid
, old_euid
, old_suid
);
450 * This function implements a generic ability to update ruid, euid,
451 * and suid. This allows you to implement the 4.4 compatible seteuid().
453 asmlinkage
long sys_setresuid(uid_t ruid
, uid_t euid
, uid_t suid
)
455 int old_ruid
= current
->uid
;
456 int old_euid
= current
->euid
;
457 int old_suid
= current
->suid
;
459 if (!capable(CAP_SETUID
)) {
460 if ((ruid
!= (uid_t
) -1) && (ruid
!= current
->uid
) &&
461 (ruid
!= current
->euid
) && (ruid
!= current
->suid
))
463 if ((euid
!= (uid_t
) -1) && (euid
!= current
->uid
) &&
464 (euid
!= current
->euid
) && (euid
!= current
->suid
))
466 if ((suid
!= (uid_t
) -1) && (suid
!= current
->uid
) &&
467 (suid
!= current
->euid
) && (suid
!= current
->suid
))
470 if (ruid
!= (uid_t
) -1) {
471 /* See above commentary about NPROC rlimit issues here. */
476 if (euid
!= (uid_t
) -1) {
477 if (euid
!= current
->euid
)
478 current
->dumpable
= 0;
479 current
->euid
= euid
;
480 current
->fsuid
= euid
;
482 if (suid
!= (uid_t
) -1)
483 current
->suid
= suid
;
485 if (!issecure(SECURE_NO_SETUID_FIXUP
)) {
486 cap_emulate_setxuid(old_ruid
, old_euid
, old_suid
);
492 asmlinkage
long sys_getresuid(uid_t
*ruid
, uid_t
*euid
, uid_t
*suid
)
496 if (!(retval
= put_user(current
->uid
, ruid
)) &&
497 !(retval
= put_user(current
->euid
, euid
)))
498 retval
= put_user(current
->suid
, suid
);
504 * Same as above, but for rgid, egid, sgid.
506 asmlinkage
long sys_setresgid(gid_t rgid
, gid_t egid
, gid_t sgid
)
508 if (!capable(CAP_SETGID
)) {
509 if ((rgid
!= (gid_t
) -1) && (rgid
!= current
->gid
) &&
510 (rgid
!= current
->egid
) && (rgid
!= current
->sgid
))
512 if ((egid
!= (gid_t
) -1) && (egid
!= current
->gid
) &&
513 (egid
!= current
->egid
) && (egid
!= current
->sgid
))
515 if ((sgid
!= (gid_t
) -1) && (sgid
!= current
->gid
) &&
516 (sgid
!= current
->egid
) && (sgid
!= current
->sgid
))
519 if (rgid
!= (gid_t
) -1)
521 if (egid
!= (gid_t
) -1) {
522 if (egid
!= current
->egid
)
523 current
->dumpable
= 0;
524 current
->egid
= egid
;
525 current
->fsgid
= egid
;
527 if (sgid
!= (gid_t
) -1)
528 current
->sgid
= sgid
;
532 asmlinkage
long sys_getresgid(gid_t
*rgid
, gid_t
*egid
, gid_t
*sgid
)
536 if (!(retval
= put_user(current
->gid
, rgid
)) &&
537 !(retval
= put_user(current
->egid
, egid
)))
538 retval
= put_user(current
->sgid
, sgid
);
545 * "setfsuid()" sets the fsuid - the uid used for filesystem checks. This
546 * is used for "access()" and for the NFS daemon (letting nfsd stay at
547 * whatever uid it wants to). It normally shadows "euid", except when
548 * explicitly set by setfsuid() or for access..
550 asmlinkage
long sys_setfsuid(uid_t uid
)
554 old_fsuid
= current
->fsuid
;
555 if (uid
== current
->uid
|| uid
== current
->euid
||
556 uid
== current
->suid
|| uid
== current
->fsuid
||
558 current
->fsuid
= uid
;
559 if (current
->fsuid
!= old_fsuid
)
560 current
->dumpable
= 0;
562 /* We emulate fsuid by essentially doing a scaled-down version
563 * of what we did in setresuid and friends. However, we only
564 * operate on the fs-specific bits of the process' effective
567 * FIXME - is fsuser used for all CAP_FS_MASK capabilities?
568 * if not, we might be a bit too harsh here.
571 if (!issecure(SECURE_NO_SETUID_FIXUP
)) {
572 if (old_fsuid
== 0 && current
->fsuid
!= 0) {
573 cap_t(current
->cap_effective
) &= ~CAP_FS_MASK
;
575 if (old_fsuid
!= 0 && current
->fsuid
== 0) {
576 cap_t(current
->cap_effective
) |=
577 (cap_t(current
->cap_permitted
) & CAP_FS_MASK
);
585 * Samma på svenska..
587 asmlinkage
long sys_setfsgid(gid_t gid
)
591 old_fsgid
= current
->fsgid
;
592 if (gid
== current
->gid
|| gid
== current
->egid
||
593 gid
== current
->sgid
|| gid
== current
->fsgid
||
595 current
->fsgid
= gid
;
596 if (current
->fsgid
!= old_fsgid
)
597 current
->dumpable
= 0;
602 asmlinkage
long sys_times(struct tms
* tbuf
)
605 * In the SMP world we might just be unlucky and have one of
606 * the times increment as we use it. Since the value is an
607 * atomically safe type this is just fine. Conceptually its
608 * as if the syscall took an instant longer to occur.
611 if (copy_to_user(tbuf
, ¤t
->times
, sizeof(struct tms
)))
617 * This needs some heavy checking ...
618 * I just haven't the stomach for it. I also don't fully
619 * understand sessions/pgrp etc. Let somebody who does explain it.
621 * OK, I think I have the protection semantics right.... this is really
622 * only important on a multi-user system anyway, to make sure one user
623 * can't send a signal to a process owned by another. -TYT, 12/12/91
625 * Auch. Had to add the 'did_exec' flag to conform completely to POSIX.
629 asmlinkage
long sys_setpgid(pid_t pid
, pid_t pgid
)
631 struct task_struct
* p
;
641 /* From this point forward we keep holding onto the tasklist lock
642 * so that our parent does not change from under us. -DaveM
644 read_lock(&tasklist_lock
);
647 p
= find_task_by_pid(pid
);
651 if (p
->p_pptr
== current
|| p
->p_opptr
== current
) {
653 if (p
->session
!= current
->session
)
658 } else if (p
!= current
)
664 struct task_struct
* tmp
;
665 for_each_task (tmp
) {
666 if (tmp
->pgrp
== pgid
&&
667 tmp
->session
== current
->session
)
677 /* All paths lead to here, thus we are safe. -DaveM */
678 read_unlock(&tasklist_lock
);
682 asmlinkage
long sys_getpgid(pid_t pid
)
685 return current
->pgrp
;
688 struct task_struct
*p
;
690 read_lock(&tasklist_lock
);
691 p
= find_task_by_pid(pid
);
696 read_unlock(&tasklist_lock
);
701 asmlinkage
long sys_getpgrp(void)
703 /* SMP - assuming writes are word atomic this is fine */
704 return current
->pgrp
;
707 asmlinkage
long sys_getsid(pid_t pid
)
710 return current
->session
;
713 struct task_struct
*p
;
715 read_lock(&tasklist_lock
);
716 p
= find_task_by_pid(pid
);
721 read_unlock(&tasklist_lock
);
726 asmlinkage
long sys_setsid(void)
728 struct task_struct
* p
;
731 read_lock(&tasklist_lock
);
733 if (p
->pgrp
== current
->pid
)
738 current
->session
= current
->pgrp
= current
->pid
;
740 current
->tty_old_pgrp
= 0;
743 read_unlock(&tasklist_lock
);
748 * Supplementary group IDs
750 asmlinkage
long sys_getgroups(int gidsetsize
, gid_t
*grouplist
)
755 * SMP: Nobody else can change our grouplist. Thus we are
761 i
= current
->ngroups
;
765 if (copy_to_user(grouplist
, current
->groups
, sizeof(gid_t
)*i
))
772 * SMP: Our groups are not shared. We can copy to/from them safely
773 * without another task interfering.
776 asmlinkage
long sys_setgroups(int gidsetsize
, gid_t
*grouplist
)
778 if (!capable(CAP_SETGID
))
780 if ((unsigned) gidsetsize
> NGROUPS
)
782 if(copy_from_user(current
->groups
, grouplist
, gidsetsize
* sizeof(gid_t
)))
784 current
->ngroups
= gidsetsize
;
788 int in_group_p(gid_t grp
)
790 if (grp
!= current
->fsgid
) {
791 int i
= current
->ngroups
;
793 gid_t
*groups
= current
->groups
;
808 * This should really be a blocking read-write lock
809 * rather than a semaphore. Anybody want to implement
812 DECLARE_MUTEX(uts_sem
);
814 asmlinkage
long sys_newuname(struct new_utsname
* name
)
819 if (copy_to_user(name
,&system_utsname
,sizeof *name
))
825 asmlinkage
long sys_sethostname(char *name
, int len
)
829 if (!capable(CAP_SYS_ADMIN
))
831 if (len
< 0 || len
> __NEW_UTS_LEN
)
835 if (!copy_from_user(system_utsname
.nodename
, name
, len
)) {
836 system_utsname
.nodename
[len
] = 0;
843 asmlinkage
long sys_gethostname(char *name
, int len
)
850 i
= 1 + strlen(system_utsname
.nodename
);
854 if (copy_to_user(name
, system_utsname
.nodename
, i
))
861 * Only setdomainname; getdomainname can be implemented by calling
864 asmlinkage
long sys_setdomainname(char *name
, int len
)
868 if (!capable(CAP_SYS_ADMIN
))
870 if (len
< 0 || len
> __NEW_UTS_LEN
)
875 if (!copy_from_user(system_utsname
.domainname
, name
, len
)) {
877 system_utsname
.domainname
[len
] = 0;
883 asmlinkage
long sys_getrlimit(unsigned int resource
, struct rlimit
*rlim
)
885 if (resource
>= RLIM_NLIMITS
)
888 return copy_to_user(rlim
, current
->rlim
+ resource
, sizeof(*rlim
))
892 asmlinkage
long sys_setrlimit(unsigned int resource
, struct rlimit
*rlim
)
894 struct rlimit new_rlim
, *old_rlim
;
896 if (resource
>= RLIM_NLIMITS
)
898 if(copy_from_user(&new_rlim
, rlim
, sizeof(*rlim
)))
900 if (new_rlim
.rlim_cur
< 0 || new_rlim
.rlim_max
< 0)
902 old_rlim
= current
->rlim
+ resource
;
903 if (((new_rlim
.rlim_cur
> old_rlim
->rlim_max
) ||
904 (new_rlim
.rlim_max
> old_rlim
->rlim_max
)) &&
905 !capable(CAP_SYS_RESOURCE
))
907 if (resource
== RLIMIT_NOFILE
) {
908 if (new_rlim
.rlim_cur
> NR_OPEN
|| new_rlim
.rlim_max
> NR_OPEN
)
911 *old_rlim
= new_rlim
;
916 * It would make sense to put struct rusage in the task_struct,
917 * except that would make the task_struct be *really big*. After
918 * task_struct gets moved into malloc'ed memory, it would
919 * make sense to do this. It will make moving the rest of the information
920 * a lot simpler! (Which we're not doing right now because we're not
921 * measuring them yet).
923 * This is SMP safe. Either we are called from sys_getrusage on ourselves
924 * below (we know we aren't going to exit/disappear and only we change our
925 * rusage counters), or we are called from wait4() on a process which is
926 * either stopped or zombied. In the zombied case the task won't get
927 * reaped till shortly after the call to getrusage(), in both cases the
928 * task being examined is in a frozen state so the counters won't change.
930 * FIXME! Get the fault counts properly!
932 int getrusage(struct task_struct
*p
, int who
, struct rusage
*ru
)
936 memset((char *) &r
, 0, sizeof(r
));
939 r
.ru_utime
.tv_sec
= CT_TO_SECS(p
->times
.tms_utime
);
940 r
.ru_utime
.tv_usec
= CT_TO_USECS(p
->times
.tms_utime
);
941 r
.ru_stime
.tv_sec
= CT_TO_SECS(p
->times
.tms_stime
);
942 r
.ru_stime
.tv_usec
= CT_TO_USECS(p
->times
.tms_stime
);
943 r
.ru_minflt
= p
->min_flt
;
944 r
.ru_majflt
= p
->maj_flt
;
945 r
.ru_nswap
= p
->nswap
;
947 case RUSAGE_CHILDREN
:
948 r
.ru_utime
.tv_sec
= CT_TO_SECS(p
->times
.tms_cutime
);
949 r
.ru_utime
.tv_usec
= CT_TO_USECS(p
->times
.tms_cutime
);
950 r
.ru_stime
.tv_sec
= CT_TO_SECS(p
->times
.tms_cstime
);
951 r
.ru_stime
.tv_usec
= CT_TO_USECS(p
->times
.tms_cstime
);
952 r
.ru_minflt
= p
->cmin_flt
;
953 r
.ru_majflt
= p
->cmaj_flt
;
954 r
.ru_nswap
= p
->cnswap
;
957 r
.ru_utime
.tv_sec
= CT_TO_SECS(p
->times
.tms_utime
+ p
->times
.tms_cutime
);
958 r
.ru_utime
.tv_usec
= CT_TO_USECS(p
->times
.tms_utime
+ p
->times
.tms_cutime
);
959 r
.ru_stime
.tv_sec
= CT_TO_SECS(p
->times
.tms_stime
+ p
->times
.tms_cstime
);
960 r
.ru_stime
.tv_usec
= CT_TO_USECS(p
->times
.tms_stime
+ p
->times
.tms_cstime
);
961 r
.ru_minflt
= p
->min_flt
+ p
->cmin_flt
;
962 r
.ru_majflt
= p
->maj_flt
+ p
->cmaj_flt
;
963 r
.ru_nswap
= p
->nswap
+ p
->cnswap
;
966 return copy_to_user(ru
, &r
, sizeof(r
)) ? -EFAULT
: 0;
969 asmlinkage
long sys_getrusage(int who
, struct rusage
*ru
)
971 if (who
!= RUSAGE_SELF
&& who
!= RUSAGE_CHILDREN
)
973 return getrusage(current
, who
, ru
);
976 asmlinkage
long sys_umask(int mask
)
978 mask
= xchg(¤t
->fs
->umask
, mask
& S_IRWXUGO
);
982 asmlinkage
long sys_prctl(int option
, unsigned long arg2
, unsigned long arg3
,
983 unsigned long arg4
, unsigned long arg5
)
989 case PR_SET_PDEATHSIG
:
995 current
->pdeath_signal
= sig
;
997 case PR_GET_PDEATHSIG
:
998 error
= put_user(current
->pdeath_signal
, (int *)arg2
);
1000 case PR_GET_DUMPABLE
:
1001 if (current
->dumpable
)
1004 case PR_SET_DUMPABLE
:
1005 if (arg2
!= 0 && arg2
!= 1) {
1009 current
->dumpable
= arg2
;