From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030734AbWF0HU6 (ORCPT ); Tue, 27 Jun 2006 03:20:58 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1030740AbWF0HUh (ORCPT ); Tue, 27 Jun 2006 03:20:37 -0400 Received: from cantor2.suse.de ([195.135.220.15]:60582 "EHLO mx2.suse.de") by vger.kernel.org with ESMTP id S1030734AbWF0HUO (ORCPT ); Tue, 27 Jun 2006 03:20:14 -0400 From: NeilBrown To: Andrew Morton Date: Tue, 27 Jun 2006 17:20:07 +1000 Message-Id: <1060627072007.26660@suse.de> X-face: [Gw_3E*Gng}4rRrKRYotwlE?.2|**#s9D Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org From: J. Bruce Fields In the typical v2/v3 case the only new filehandles used as arguments to operations are filehandles taken directly off the wire, which don't get dentries until fh_verify() is called. But in v4 the filehandles that are arguments to operations were often created by previous operations (putrootfh, lookup, etc.) using fh_compose, which sets the dentry in the filehandle without calling nfsd_setuser(). This also means that, for example, if filesystem B is mounted on filesystem A, and filesystem A is exported without root-squashing, then a client can bypass the rootsquashing on B using a compound that starts at a filehandle in A, crosses into B using lookups, and then does stuff in B. Signed-off-by: J. Bruce Fields ### Diffstat output ./fs/nfsd/nfsfh.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff .prev/fs/nfsd/nfsfh.c ./fs/nfsd/nfsfh.c --- .prev/fs/nfsd/nfsfh.c 2006-06-27 12:16:27.000000000 +1000 +++ ./fs/nfsd/nfsfh.c 2006-06-27 14:41:52.000000000 +1000 @@ -187,13 +187,6 @@ fh_verify(struct svc_rqst *rqstp, struct goto out; } - /* Set user creds for this exportpoint */ - error = nfsd_setuser(rqstp, exp); - if (error) { - error = nfserrno(error); - goto out; - } - /* * Look up the dentry using the NFS file handle. */ @@ -251,6 +244,14 @@ fh_verify(struct svc_rqst *rqstp, struct } cache_get(&exp->h); + /* Set user creds for this exportpoint; necessary even in the "just + * checking" case because this may be a filehandle that was created by + * fh_compose, and that is about to be used in another nfsv4 compound + * operation */ + error = nfserrno(nfsd_setuser(rqstp, exp)); + if (error) + goto out; + error = nfsd_mode_check(rqstp, dentry->d_inode->i_mode, type); if (error) goto out;