From patchwork Tue Aug 5 18:21:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "J. Bruce Fields" X-Patchwork-Id: 4681071 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 40110C0338 for ; Tue, 5 Aug 2014 18:22:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8425F201BC for ; Tue, 5 Aug 2014 18:21:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 71932201CD for ; Tue, 5 Aug 2014 18:21:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754967AbaHESVh (ORCPT ); Tue, 5 Aug 2014 14:21:37 -0400 Received: from fieldses.org ([174.143.236.118]:35547 "EHLO fieldses.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753760AbaHESVf (ORCPT ); Tue, 5 Aug 2014 14:21:35 -0400 Received: from bfields by fieldses.org with local (Exim 4.76) (envelope-from ) id 1XEjMd-0005ut-0Z; Tue, 05 Aug 2014 14:21:35 -0400 Date: Tue, 5 Aug 2014 14:21:34 -0400 From: "J. Bruce Fields" To: Steve Dickson Cc: Rishi Agrawal , "linux-nfs@vger.kernel.org" , Rajesh Ghanekar , Ram Pandiri , Sreeharsha Sarabu , Abhijit Dey , Tushar Shinde , "bfields@redhat.com" Subject: Re: [PATCH] nfsd: allow turning off nfsv3 readdir_plus Message-ID: <20140805182134.GQ23341@fieldses.org> References: <20AEB6A025F81A4288597093171D1B5719CF5813D2@APJ1XCHEVSPIN35.SYMC.SYMANTEC.COM> <53DF992D.6090404@RedHat.com> <20140804152411.GB23341@fieldses.org> <20140804214646.GK23341@fieldses.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20140804214646.GK23341@fieldses.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Aug 04, 2014 at 05:46:47PM -0400, J. Bruce Fields wrote: > On Mon, Aug 04, 2014 at 11:24:11AM -0400, bfields wrote: > > +static int > > +nfsd3_is_readdirplus_supported(struct svc_rqst *rqstp, struct svc_fh *fhp) > > +{ > > + struct svc_export *exp; > > + int supported = 1; /* fall back to readdirplus supported in case of errors.*/ > > + int err; > > + > > + err = fh_verify(rqstp, fhp, S_IFDIR, NFSD_MAY_READ); > > + if (err) { > > + goto out; > > + } > > Actually, this isn't right: errors from fh_verify should be returned to > the client or weird things could happen (e.g. what should have been a > transient DELAY error could result in the client turning off > readdirplus). Apologies, I misread: as the comment above notes, it falls back on allowing readdirplus when this fails, so I don't think there's a real bug here. > And MAY_READ is more than nfsd_readdir actually asks for, > I think, probably should just be MAY_NOP here. > > I'll fix that up.--b. But it's probably still better to return the fh_verify error on failure, as follows. --b. --- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index 72ffd7cce3c3..30a739d896ff 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c @@ -1145,6 +1145,7 @@ static struct flags { { NFSEXP_ALLSQUASH, {"all_squash", ""}}, { NFSEXP_ASYNC, {"async", "sync"}}, { NFSEXP_GATHERED_WRITES, {"wdelay", "no_wdelay"}}, + { NFSEXP_NOREADDIRPLUS, {"nordirplus", ""}}, { NFSEXP_NOHIDE, {"nohide", ""}}, { NFSEXP_CROSSMOUNT, {"crossmnt", ""}}, { NFSEXP_NOSUBTREECHECK, {"no_subtree_check", ""}}, diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c index fa2525b2e9d7..247b06fb400d 100644 --- a/fs/nfsd/nfs3proc.c +++ b/fs/nfsd/nfs3proc.c @@ -471,6 +471,14 @@ nfsd3_proc_readdirplus(struct svc_rqst *rqstp, struct nfsd3_readdirargs *argp, resp->buflen = resp->count; resp->rqstp = rqstp; offset = argp->cookie; + + nfserr = fh_verify(rqstp, &resp->fh, S_IFDIR, NFSD_MAY_NOP); + if (nfserr) + RETURN_STATUS(nfserr); + + if (resp->fh.fh_export->ex_flags & NFSEXP_NOREADDIRPLUS) + RETURN_STATUS(nfserr_notsupp); + nfserr = nfsd_readdir(rqstp, &resp->fh, &offset, &resp->common, diff --git a/include/uapi/linux/nfsd/export.h b/include/uapi/linux/nfsd/export.h index cf47c313794e..584b6ef3a5e8 100644 --- a/include/uapi/linux/nfsd/export.h +++ b/include/uapi/linux/nfsd/export.h @@ -28,7 +28,8 @@ #define NFSEXP_ALLSQUASH 0x0008 #define NFSEXP_ASYNC 0x0010 #define NFSEXP_GATHERED_WRITES 0x0020 -/* 40 80 100 currently unused */ +#define NFSEXP_NOREADDIRPLUS 0x0040 +/* 80 100 currently unused */ #define NFSEXP_NOHIDE 0x0200 #define NFSEXP_NOSUBTREECHECK 0x0400 #define NFSEXP_NOAUTHNLM 0x0800 /* Don't authenticate NLM requests - just trust */ @@ -47,7 +48,7 @@ */ #define NFSEXP_V4ROOT 0x10000 /* All flags that we claim to support. (Note we don't support NOACL.) */ -#define NFSEXP_ALLFLAGS 0x17E3F +#define NFSEXP_ALLFLAGS 0x1FE7F /* The flags that may vary depending on security flavor: */ #define NFSEXP_SECINFO_FLAGS (NFSEXP_READONLY | NFSEXP_ROOTSQUASH \