]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/vfs/vfs_subr.c
xnu-3248.40.184.tar.gz
[apple/xnu.git] / bsd / vfs / vfs_subr.c
index 9fec68cd43b416d124bd3681c35b48bc5cda19e1..4f31d45e7b2f4ee977f786e0494ebdce8a0e6423 100644 (file)
@@ -7425,6 +7425,9 @@ vnode_authorize_callback_int(__unused kauth_cred_t unused_cred, __unused void *i
                        goto out;
                }
                
+               /* Assume that there were DENYs so we don't wrongly cache KAUTH_VNODE_SEARCHBYANYONE */
+               found_deny = TRUE;
+               
                KAUTH_DEBUG("%p    ALLOWED - caller is superuser", vp);
        }
 out:
@@ -7447,6 +7450,10 @@ out:
                 * deny execute, we can synthesize a global right that allows anyone to 
                 * traverse this directory during a pathname lookup without having to
                 * match the credential associated with this cache of rights.
+                *
+                * Note that we can correctly cache KAUTH_VNODE_SEARCHBYANYONE
+                * only if we actually check ACLs which we don't for root. As
+                * a workaround, the lookup fast path checks for root.
                 */
                if (!VATTR_IS_SUPPORTED(&va, va_mode) ||
                    ((va.va_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) ==
@@ -7807,10 +7814,10 @@ vnode_authattr(vnode_t vp, struct vnode_attr *vap, kauth_action_t *actionp, vfs_
         * If the size is being set, make sure it's not a directory.
         */
        if (VATTR_IS_ACTIVE(vap, va_data_size)) {
-               /* size is meaningless on a directory, don't permit this */
-               if (vnode_isdir(vp)) {
-                       KAUTH_DEBUG("ATTR - ERROR: size change requested on a directory");
-                       error = EISDIR;
+               /* size is only meaningful on regular files, don't permit otherwise */
+               if (!vnode_isreg(vp)) {
+                       KAUTH_DEBUG("ATTR - ERROR: size change requested on non-file");
+                       error = vnode_isdir(vp) ? EISDIR : EINVAL;
                        goto out;
                }
        }