From owner-freebsd-bugs@FreeBSD.ORG Wed Apr 24 09:50:02 2013 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 8250B366 for ; Wed, 24 Apr 2013 09:50:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id 687921ACA for ; Wed, 24 Apr 2013 09:50:02 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.6/8.14.6) with ESMTP id r3O9o2T0065498 for ; Wed, 24 Apr 2013 09:50:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.6/8.14.6/Submit) id r3O9o2Rj065497; Wed, 24 Apr 2013 09:50:02 GMT (envelope-from gnats) Resent-Date: Wed, 24 Apr 2013 09:50:02 GMT Resent-Message-Id: <201304240950.r3O9o2Rj065497@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Andrey Simonenko Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 81B052EB for ; Wed, 24 Apr 2013 09:44:18 +0000 (UTC) (envelope-from simon@comsys.ntu-kpi.kiev.ua) Received: from comsys.kpi.ua (comsys.kpi.ua [77.47.192.42]) by mx1.freebsd.org (Postfix) with ESMTP id 405901A88 for ; Wed, 24 Apr 2013 09:44:17 +0000 (UTC) Received: from pm513-1.comsys.kpi.ua ([10.18.52.101] helo=pm513-1.comsys.ntu-kpi.kiev.ua) by comsys.kpi.ua with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1UUwFL-0001vI-86 for FreeBSD-gnats-submit@freebsd.org; Wed, 24 Apr 2013 12:44:15 +0300 Received: by pm513-1.comsys.ntu-kpi.kiev.ua (Postfix, from userid 1001) id AC0621E089; Wed, 24 Apr 2013 12:44:14 +0300 (EEST) Message-Id: <20130424094414.GA18874@pm513-1.comsys.ntu-kpi.kiev.ua> Date: Wed, 24 Apr 2013 12:44:14 +0300 From: Andrey Simonenko To: FreeBSD-gnats-submit@freebsd.org Subject: kern/178103: Correct support of index files for WebNFS exports X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Apr 2013 09:50:02 -0000 >Number: 178103 >Category: kern >Synopsis: Correct support of index files for WebNFS exports >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Wed Apr 24 09:50:00 UTC 2013 >Closed-Date: >Last-Modified: >Originator: Andrey Simonenko >Release: FreeBSD 10-CURRENT amd64 >Organization: >Environment: >Description: RFC 2055 describes index files for WebNFS exports. The exports(5) manual page has description of the -index option, but this option does not work because of mistakes in mountd and kernel part of the NFS server. The following change: 1. corrects handling of the -index option in usr.sbin/mountd/mountd.c; 2. corrects fetching of the index file in sys/kern/vfs_export.c; 3. corrects locking if a directory does not have the index file in sys/nfsserver/nfs_serv.c This change is for the old NFS server, since new NFS server uses another API for WebNFS settings and its logic of index files does not correspond to RFC 2055. >How-To-Repeat: Export some file system with options "-public -index 123", then mount it using NFSv2/3 client and public filehandle. Create a regular file "123" in some directory and try to read that directory on a client. Do the same, but create directory "123" with some content. In both cases the content of a directory with the index file in NFS mounted file system should be altered. >Fix: --------------------------------------------------------------------------- This is for mountd: --- mountd.c.orig 2013-02-22 11:36:42.000000000 +0200 +++ mountd.c 2013-04-24 11:36:31.000000000 +0300 @@ -68,6 +68,7 @@ __FBSDID("$FreeBSD: src/usr.sbin/mountd/ #include #include +#include #include #include #include @@ -2232,7 +2233,14 @@ do_opt(char **cpp, char **endcpp, struct *exflagsp |= (MNT_EXPUBLIC|MNT_EXRDONLY|MNT_EXPORTANON); opt_flags |= OP_MAPALL; } else if (cpoptarg && !strcmp(cpopt, "index")) { + if (strlen(cpoptarg) > MAXNAMLEN) { + syslog(LOG_ERR, "too long file name"); + return (1); + } ep->ex_indexfile = strdup(cpoptarg); + if (ep->ex_indexfile == NULL) + out_of_mem(); + usedarg++; } else if (!strcmp(cpopt, "quiet")) { opt_flags |= OP_QUIET; } else if (cpoptarg && !strcmp(cpopt, "sec")) { --------------------------------------------------------------------------- This is for the kernel: diff -ruNp sys.orig/kern/vfs_export.c sys/kern/vfs_export.c --- sys.orig/kern/vfs_export.c 2013-02-22 11:36:29.000000000 +0200 +++ sys/kern/vfs_export.c 2013-04-12 14:36:18.000000000 +0300 @@ -387,7 +387,7 @@ vfs_setpublicfs(struct mount *mp, struct * If an indexfile was specified, pull it in. */ if (argp->ex_indexfile != NULL) { - if (nfs_pub.np_index != NULL) + if (nfs_pub.np_index == NULL) nfs_pub.np_index = malloc(MAXNAMLEN + 1, M_TEMP, M_WAITOK); error = copyinstr(argp->ex_indexfile, nfs_pub.np_index, diff -ruNp sys.orig/nfsserver/nfs_serv.c sys/nfsserver/nfs_serv.c --- sys.orig/nfsserver/nfs_serv.c 2013-03-09 13:01:24.000000000 +0200 +++ sys/nfsserver/nfs_serv.c 2013-04-11 12:07:43.000000000 +0300 @@ -583,7 +583,8 @@ nfsrv_lookup(struct nfsrv_descript *nfsd vrele(nd.ni_startdir); nd.ni_startdir = NULL; ndp = &ind; - } + } else + vn_lock(nd.ni_vp, LK_EXCLUSIVE | LK_RETRY); error = 0; } /* >Release-Note: >Audit-Trail: >Unformatted: