From 13125fb720bd9efb48d9a37ef0d155ab4f5eb56f Mon Sep 17 00:00:00 2001 From: manu Date: Fri, 6 Oct 2017 09:02:36 +0000 Subject: [PATCH] vfs_export_lookup: Fix r324054 When using the default address list nam is still valid, the code in r324054 assumed that is was NULL. Reported by: Guy Yur Tested by: Guy Yur --- sys/kern/vfs_export.c | 45 +++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/sys/kern/vfs_export.c b/sys/kern/vfs_export.c index d1dbe4fa9886..5fce9ed4b28d 100644 --- a/sys/kern/vfs_export.c +++ b/sys/kern/vfs_export.c @@ -459,34 +459,33 @@ vfs_export_lookup(struct mount *mp, struct sockaddr *nam) return (NULL); /* - * If no address is provided, use the default if it exists. + * Lookup in the export list */ - if (nam == NULL) { - if ((mp->mnt_flag & MNT_DEFEXPORTED) != 0) - return (&nep->ne_defexported); - return (NULL); + if (nam != NULL) { + saddr = nam; + rnh = NULL; + switch (saddr->sa_family) { + case AF_INET: + rnh = nep->ne4; + break; + case AF_INET6: + rnh = nep->ne6; + break; + } + if (rnh != NULL) { + RADIX_NODE_HEAD_RLOCK(rnh); + np = (struct netcred *) (*rnh->rnh_matchaddr)(saddr, &rnh->rh); + RADIX_NODE_HEAD_RUNLOCK(rnh); + if (np != NULL && (np->netc_rnodes->rn_flags & RNF_ROOT) != 0) + return (NULL); + } } /* - * Lookup in the export list + * If no address match, use the default if it exists. */ - saddr = nam; - rnh = NULL; - switch (saddr->sa_family) { - case AF_INET: - rnh = nep->ne4; - break; - case AF_INET6: - rnh = nep->ne6; - break; - } - if (rnh != NULL) { - RADIX_NODE_HEAD_RLOCK(rnh); - np = (struct netcred *) (*rnh->rnh_matchaddr)(saddr, &rnh->rh); - RADIX_NODE_HEAD_RUNLOCK(rnh); - if (np != NULL && (np->netc_rnodes->rn_flags & RNF_ROOT) != 0) - return (NULL); - } + if (np == NULL && (mp->mnt_flag & MNT_DEFEXPORTED) != 0) + return (&nep->ne_defexported); return (np); }