]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/nfs/nfs_subs.c
xnu-4903.221.2.tar.gz
[apple/xnu.git] / bsd / nfs / nfs_subs.c
index 8496093a9fac2230ec36d2b81f5772ba6ac027ea..0702fbed92433ea410d462d5beda04b020168ec8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2014 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2016 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
@@ -1688,8 +1688,15 @@ nfs_getattrcache(nfsnode_t np, struct nfs_vattr *nvaper, int flags)
         * and return cached attributes.
         */
        if (!nfs_use_cache(nmp)) {
-               timeo = nfs_attrcachetimeout(np);
                microuptime(&nowup);
+               if (np->n_attrstamp > nowup.tv_sec) {
+                       printf("NFS: Attribute time stamp is in the future by %ld seconds. Invalidating cache\n",
+                              np->n_attrstamp - nowup.tv_sec);
+                       NATTRINVALIDATE(np);
+                       NACCESSINVALIDATE(np);
+                       return (ENOENT);
+               }
+               timeo = nfs_attrcachetimeout(np);
                if ((nowup.tv_sec - np->n_attrstamp) >= timeo) {
                        FSDBG(528, np, 0, 0xffffff02, ENOENT);
                        OSAddAtomic64(1, &nfsstats.attrcache_misses);
@@ -2188,6 +2195,7 @@ nfsrv_namei(
        cnp->cn_flags |= NOCROSSMOUNT;
        cnp->cn_nameptr = cnp->cn_pnbuf;
        nip->ni_usedvp = nip->ni_startdir = dp;
+       nip->ni_rootdir = rootvnode;
 
        /*
         * And call lookup() to do the real work
@@ -3109,6 +3117,7 @@ nfsrv_export(struct user_nfs_export_args *unxa, vfs_context_t ctx)
                                        xnd.ni_cnd.cn_nameptr = xnd.ni_cnd.cn_pnbuf = path;
                                        xnd.ni_startdir = mvp;
                                        xnd.ni_usedvp   = mvp;
+                                       xnd.ni_rootdir = rootvnode;
                                        xnd.ni_cnd.cn_context = ctx;
                                        while ((error = lookup(&xnd)) == ERECYCLE) {
                                                xnd.ni_cnd.cn_flags = LOCKLEAF;
@@ -3238,7 +3247,7 @@ nfsrv_check_exports_allow_address(mbuf_t nam)
 {
        struct nfs_exportfs             *nxfs;
        struct nfs_export               *nx;
-       struct nfs_export_options       *nxo;
+       struct nfs_export_options       *nxo = NULL;
 
        if (nam == NULL)
                return (EACCES);
@@ -3270,6 +3279,10 @@ nfsrv_export_lookup(struct nfs_export *nx, mbuf_t nam)
        /* Lookup in the export list first. */
        if (nam != NULL) {
                saddr = mbuf_data(nam);
+               if (saddr->sa_family > AF_MAX) {
+                       /* Bogus sockaddr?  Don't match anything. */
+                       return (NULL);
+               }
                rnh = nx->nx_rtable[saddr->sa_family];
                if (rnh != NULL) {
                        no = (struct nfs_netopt *)