From patchwork Fri Jul 31 20:05:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "J. Bruce Fields" X-Patchwork-Id: 6916631 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 13AD29F358 for ; Fri, 31 Jul 2015 20:05:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E952A2041E for ; Fri, 31 Jul 2015 20:05:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CEB34203A9 for ; Fri, 31 Jul 2015 20:05:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751533AbbGaUFg (ORCPT ); Fri, 31 Jul 2015 16:05:36 -0400 Received: from fieldses.org ([173.255.197.46]:34495 "EHLO fieldses.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751183AbbGaUFf (ORCPT ); Fri, 31 Jul 2015 16:05:35 -0400 Received: by fieldses.org (Postfix, from userid 2815) id A66473C2F; Fri, 31 Jul 2015 16:05:34 -0400 (EDT) Date: Fri, 31 Jul 2015 16:05:34 -0400 From: "J. Bruce Fields" To: Jeff Layton Cc: linux-nfs@vger.kernel.org Subject: Re: [PATCH] nfsd: do nfs4_check_fh in nfs4_check_file instead of nfs4_check_olstateid Message-ID: <20150731200534.GA20543@fieldses.org> References: <1438253866-7393-1-git-send-email-jeff.layton@primarydata.com> <20150730151641.GE9349@fieldses.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150730151641.GE9349@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=-8.3 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 Thu, Jul 30, 2015 at 11:16:41AM -0400, J. Bruce Fields wrote: > On Thu, Jul 30, 2015 at 06:57:46AM -0400, Jeff Layton wrote: > > Currently, preprocess_stateid_op calls nfs4_check_olstateid which > > verifies that the open stateid corresponds to the current_fh in the > > call by calling nfs4_check_fh. > > > > If the stateid is a NFS4_DELEG_STID however, then no such check is > > done. Move the call to nfs4_check_fh into nfs4_check_file instead > > so that it can be done for all stateid types. > > Thanks, applying for 4.2 and -stable with a note that this can screw up > permissions checking later in nfs4_check_file. By the way I also had to apply the following to avoid a NULL dereference in the special-stateid case (when we'll jump to the "done:" label with "s" still NULL). Thanks to pynfs4.0 RD1 for catching that.... --b. Reviewed-by: Jeff Layton --- 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/nfs4state.c b/fs/nfsd/nfs4state.c index 5cee7f2c4802..95202719a1fd 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -4615,10 +4615,6 @@ nfs4_check_file(struct svc_rqst *rqstp, struct svc_fh *fhp, struct nfs4_stid *s, struct file *file; __be32 status; - status = nfs4_check_fh(fhp, s); - if (status) - return status; - file = nfs4_find_file(s, flags); if (file) { status = nfsd_permission(rqstp, fhp->fh_export, fhp->fh_dentry, @@ -4691,6 +4687,9 @@ nfs4_preprocess_stateid_op(struct svc_rqst *rqstp, status = nfserr_bad_stateid; break; } + if (status) + goto out; + status = nfs4_check_fh(fhp, s); done: if (!status && filpp)