output_kernel_symbols(struct proc *p)
{
struct vnode *vp;
- kauth_cred_t cred = p->p_ucred; /* XXX */
+ kauth_cred_t cred = p->p_ucred; /* XXX unsafe */
struct vnode_attr va;
struct vfs_context context;
struct load_command *cmd;
orig_mh = NULL;
orig_st = NULL;
+ context.vc_proc = p;
+ context.vc_ucred = kauth_cred_proc_ref(p);
+
// Dispose of unnecessary gumf, the booter doesn't need to load these
rc_mh = IODTGetLoaderInfo("Kernel-__HEADER",
(void **)&orig_mh, &orig_mhsize);
if (rootdevice[0] == 'e' && rootdevice[1] == 'n')
goto out;
- context.vc_proc = p;
- context.vc_ucred = cred;
-
if ((error = vnode_open("mach.sym", (O_CREAT | FWRITE), (S_IRUSR | S_IRGRP | S_IROTH), 0, &vp, &context)))
goto out;
if (!error) error = error1;
}
+ kauth_cred_unref(&context.vc_ucred);
return(error);
}
/*
struct kern_direct_file_io_ref_t * ref;
struct proc *p;
- struct ucred *cred;
struct vnode_attr va;
int error;
off_t f_offset;
ref->vp = NULL;
p = current_proc(); // kernproc;
- cred = p->p_ucred;
ref->context.vc_proc = p;
- ref->context.vc_ucred = cred;
+ ref->context.vc_ucred = kauth_cred_proc_ref(p);
if ((error = vnode_open(name, (O_CREAT | FWRITE), (0), 0, &ref->vp, &ref->context)))
goto out;
kprintf("kern_open_file_for_direct_io(%d)\n", error);
if (error && ref) {
- if (ref->vp) {
- vnode_close(ref->vp, FWRITE, &ref->context);
- ref->vp = NULLVP;
- }
-
- kfree(ref, sizeof(struct kern_direct_file_io_ref_t));
- ref = NULL;
+ if (ref->vp) {
+ vnode_close(ref->vp, FWRITE, &ref->context);
+ ref->vp = NULLVP;
+ }
+
+ kauth_cred_unref(&ref->context.vc_ucred);
+ kfree(ref, sizeof(struct kern_direct_file_io_ref_t));
+ ref = NULL;
}
return(ref);
kprintf("vnode_close(%d)\n", error);
ref->vp = NULLVP;
}
+ kauth_cred_unref(&ref->context.vc_ucred);
kfree(ref, sizeof(struct kern_direct_file_io_ref_t));
}
}