nfsfh.c (3eb66e91a25497065c5322b1268cbc3953642227) nfsfh.c (f01274a9335307eca729b5d12609976afcf21530)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * NFS server file handle treatment.
4 *
5 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
6 * Portions Copyright (C) 1999 G. Allen Morris III <gam3@acm.org>
7 * Extensive rewrite by Neil Brown <neilb@cse.unsw.edu.au> Southern-Spring 1999
8 * ... and again Southern-Winter 2001 to support export_operations
9 */
10
11#include <linux/exportfs.h>
12
13#include <linux/sunrpc/svcauth_gss.h>
14#include "nfsd.h"
15#include "vfs.h"
16#include "auth.h"
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * NFS server file handle treatment.
4 *
5 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
6 * Portions Copyright (C) 1999 G. Allen Morris III <gam3@acm.org>
7 * Extensive rewrite by Neil Brown <neilb@cse.unsw.edu.au> Southern-Spring 1999
8 * ... and again Southern-Winter 2001 to support export_operations
9 */
10
11#include <linux/exportfs.h>
12
13#include <linux/sunrpc/svcauth_gss.h>
14#include "nfsd.h"
15#include "vfs.h"
16#include "auth.h"
17#include "trace.h"
17
18#define NFSDDBG_FACILITY NFSDDBG_FH
19
20
21/*
22 * our acceptability function.
23 * if NOSUBTREECHECK, accept anything
24 * if not, require that we can walk up to exp->ex_dentry

--- 179 unchanged lines hidden (view full) ---

204 /* assume old filehandle format */
205 xdev = old_decode_dev(fh->ofh_xdev);
206 xino = u32_to_ino_t(fh->ofh_xino);
207 mk_fsid(FSID_DEV, tfh, xdev, xino, 0, NULL);
208 exp = rqst_exp_find(rqstp, FSID_DEV, tfh);
209 }
210
211 error = nfserr_stale;
18
19#define NFSDDBG_FACILITY NFSDDBG_FH
20
21
22/*
23 * our acceptability function.
24 * if NOSUBTREECHECK, accept anything
25 * if not, require that we can walk up to exp->ex_dentry

--- 179 unchanged lines hidden (view full) ---

205 /* assume old filehandle format */
206 xdev = old_decode_dev(fh->ofh_xdev);
207 xino = u32_to_ino_t(fh->ofh_xino);
208 mk_fsid(FSID_DEV, tfh, xdev, xino, 0, NULL);
209 exp = rqst_exp_find(rqstp, FSID_DEV, tfh);
210 }
211
212 error = nfserr_stale;
212 if (PTR_ERR(exp) == -ENOENT)
213 return error;
213 if (IS_ERR(exp)) {
214 trace_nfsd_set_fh_dentry_badexport(rqstp, fhp, PTR_ERR(exp));
214
215
215 if (IS_ERR(exp))
216 if (PTR_ERR(exp) == -ENOENT)
217 return error;
218
216 return nfserrno(PTR_ERR(exp));
219 return nfserrno(PTR_ERR(exp));
220 }
217
218 if (exp->ex_flags & NFSEXP_NOSUBTREECHECK) {
219 /* Elevate privileges so that the lack of 'r' or 'x'
220 * permission on some parent directory will
221 * not stop exportfs_decode_fh from being able
222 * to reconnect a directory into the dentry cache.
223 * The same problem can affect "SUBTREECHECK" exports,
224 * but as nfsd_acceptable depends on correct

--- 37 unchanged lines hidden (view full) ---

262 fileid_type = fh->fh_fileid_type;
263
264 if (fileid_type == FILEID_ROOT)
265 dentry = dget(exp->ex_path.dentry);
266 else {
267 dentry = exportfs_decode_fh(exp->ex_path.mnt, fid,
268 data_left, fileid_type,
269 nfsd_acceptable, exp);
221
222 if (exp->ex_flags & NFSEXP_NOSUBTREECHECK) {
223 /* Elevate privileges so that the lack of 'r' or 'x'
224 * permission on some parent directory will
225 * not stop exportfs_decode_fh from being able
226 * to reconnect a directory into the dentry cache.
227 * The same problem can affect "SUBTREECHECK" exports,
228 * but as nfsd_acceptable depends on correct

--- 37 unchanged lines hidden (view full) ---

266 fileid_type = fh->fh_fileid_type;
267
268 if (fileid_type == FILEID_ROOT)
269 dentry = dget(exp->ex_path.dentry);
270 else {
271 dentry = exportfs_decode_fh(exp->ex_path.mnt, fid,
272 data_left, fileid_type,
273 nfsd_acceptable, exp);
274 if (IS_ERR_OR_NULL(dentry))
275 trace_nfsd_set_fh_dentry_badhandle(rqstp, fhp,
276 dentry ? PTR_ERR(dentry) : -ESTALE);
270 }
271 if (dentry == NULL)
272 goto out;
273 if (IS_ERR(dentry)) {
274 if (PTR_ERR(dentry) != -EINVAL)
275 error = nfserrno(PTR_ERR(dentry));
276 goto out;
277 }

--- 429 unchanged lines hidden ---
277 }
278 if (dentry == NULL)
279 goto out;
280 if (IS_ERR(dentry)) {
281 if (PTR_ERR(dentry) != -EINVAL)
282 error = nfserrno(PTR_ERR(dentry));
283 goto out;
284 }

--- 429 unchanged lines hidden ---