X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/743b15655a24ee3fe9f458f383003e011db0558f..13fec9890cf095cc781fdf7b8917cb03bf32dd4c:/bsd/vfs/vfs_vnops.c diff --git a/bsd/vfs/vfs_vnops.c b/bsd/vfs/vfs_vnops.c index 3eb3f1522..402d876ea 100644 --- a/bsd/vfs/vfs_vnops.c +++ b/bsd/vfs/vfs_vnops.c @@ -600,7 +600,19 @@ vn_write(struct fileproc *fp, struct uio *uio, kauth_cred_t cred, * Set the credentials on successful writes */ if ((error == 0) && (vp->v_tag == VT_NFS) && (UBCINFOEXISTS(vp))) { - ubc_setcred(vp, p); + /* + * When called from aio subsystem, we only have the proc from + * which to get the credential, at this point, so use that + * instead. This means aio functions are incompatible with + * per-thread credentials (aio operations are proxied). We + * can't easily correct the aio vs. settid race in this case + * anyway, so we disallow it. + */ + if ((flags & FOF_PCRED) == 0) { + ubc_setthreadcred(vp, p, current_thread()); + } else { + ubc_setcred(vp, p); + } } (void)vnode_put(vp); return (error);