]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/kern/kern_xxx.c
xnu-7195.50.7.100.1.tar.gz
[apple/xnu.git] / bsd / kern / kern_xxx.c
index 386d06971508d20e9ee966b57e612948000877ad..2e111de759bd15b14310453dbfa7fe584efe61be 100644 (file)
 #if CONFIG_MACF
 #include <security/mac_framework.h>
 #endif
+#if CONFIG_ATM
+#include <atm/atm_internal.h>
+#endif
 
-int pshm_cache_purge_all(proc_t p);
-int psem_cache_purge_all(proc_t p);
+extern int psem_cache_purge_all(proc_t p);
+extern int pshm_cache_purge_all(proc_t p);
+extern void reset_osvariant_status(void);
+extern void reset_osreleasetype(void);
 
 int
 reboot(struct proc *p, struct reboot_args *uap, __unused int32_t *retval)
@@ -104,8 +109,10 @@ reboot(struct proc *p, struct reboot_args *uap, __unused int32_t *retval)
 
        if ((error = suser(kauth_cred_get(), &p->p_acflag))) {
 #if (DEVELOPMENT || DEBUG)
-               /* allow non-root user to call panic on dev/debug kernels */
-               if (!(uap->opt & RB_PANIC)) {
+               if (uap->opt & RB_PANIC) {
+                       /* clear 'error' to allow non-root users to call panic on dev/debug kernels */
+                       error = 0;
+               } else {
                        return error;
                }
 #else
@@ -113,13 +120,12 @@ reboot(struct proc *p, struct reboot_args *uap, __unused int32_t *retval)
 #endif
        }
 
-       if (uap->opt & RB_COMMAND) {
-               return ENOSYS;
-       }
-
        if (uap->opt & RB_PANIC && uap->msg != USER_ADDR_NULL) {
-               if (copyinstr(uap->msg, (void *)message, sizeof(message), (size_t *)&dummy)) {
+               int copy_error = copyinstr(uap->msg, (void *)message, sizeof(message), (size_t *)&dummy);
+               if (copy_error != 0 && copy_error != ENAMETOOLONG) {
                        strncpy(message, "user space RB_PANIC message copyin failed", sizeof(message) - 1);
+               } else {
+                       message[sizeof(message) - 1] = '\0';
                }
        }
 
@@ -147,6 +153,9 @@ skip_cred_check:
        return error;
 }
 
+extern void OSKextResetAfterUserspaceReboot(void);
+extern void zone_gc(boolean_t);
+
 int
 usrctl(struct proc *p, __unused struct usrctl_args *uap, __unused int32_t *retval)
 {
@@ -154,12 +163,28 @@ usrctl(struct proc *p, __unused struct usrctl_args *uap, __unused int32_t *retva
                return EPERM;
        }
 
-       int error = 0;
-       error = pshm_cache_purge_all(p);
-       if (error) {
-               return error;
-       }
+       reset_osvariant_status();
+       reset_osreleasetype();
 
-       error = psem_cache_purge_all(p);
-       return error;
+#if CONFIG_ATM
+       atm_reset();
+#endif
+
+#if CONFIG_EXT_RESOLVER
+       /*
+        * We're doing a user space reboot.  We are guaranteed that the
+        * external identity resolver is gone, so ensure that everything
+        * comes back up as with fresh-boot just in case it didn't go
+        * down cleanly.
+        */
+       kauth_resolver_identity_reset();
+#endif /* CONFIG_EXT_RESOLVER */
+
+       OSKextResetAfterUserspaceReboot();
+       int shm_error = pshm_cache_purge_all(p);
+       int sem_error = psem_cache_purge_all(p);
+
+       zone_gc(FALSE);
+
+       return shm_error != 0 ? shm_error : sem_error;
 }