Lines Matching +full:pre +full:- +full:verified

1 // SPDX-License-Identifier: GPL-2.0
7 * Extensive rewrite by Neil Brown <neilb@cse.unsw.edu.au> Southern-Spring 1999
8 * ... and again Southern-Winter 2001 to support export_operations
25 * if not, require that we can walk up to exp->ex_dentry
35 if (exp->ex_flags & NFSEXP_NOSUBTREECHECK) in nfsd_acceptable()
39 while (tdentry != exp->ex_path.dentry && !IS_ROOT(tdentry)) { in nfsd_acceptable()
52 if (tdentry != exp->ex_path.dentry) in nfsd_acceptable()
54 rv = (tdentry == exp->ex_path.dentry); in nfsd_acceptable()
67 umode_t mode = d_inode(dentry)->i_mode & S_IFMT; in nfsd_mode_check()
97 if (cred->cr_flavor >= RPC_AUTH_GSS) in nfsd_originating_port_ok()
99 return test_bit(RQ_SECURE, &rqstp->rq_flags); in nfsd_originating_port_ok()
121 if (!(exp->ex_flags & NFSEXP_V4ROOT)) in check_pseudo_root()
135 if (unlikely(dentry != exp->ex_path.dentry)) in check_pseudo_root()
151 struct knfsd_fh *fh = &fhp->fh_handle; in nfsd_set_fh_dentry()
156 int data_left = fh->fh_size/4; in nfsd_set_fh_dentry()
161 if (fh->fh_size == 0) in nfsd_set_fh_dentry()
164 if (fh->fh_version != 1) in nfsd_set_fh_dentry()
167 if (--data_left < 0) in nfsd_set_fh_dentry()
169 if (fh->fh_auth_type != 0) in nfsd_set_fh_dentry()
171 len = key_len(fh->fh_fsid_type) / 4; in nfsd_set_fh_dentry()
174 if (fh->fh_fsid_type == FSID_MAJOR_MINOR) { in nfsd_set_fh_dentry()
179 fh->fh_fsid_type = FSID_ENCODE_DEV; in nfsd_set_fh_dentry()
181 * struct knfsd_fh uses host-endian fields, which are in nfsd_set_fh_dentry()
182 * sometimes used to hold net-endian values. This in nfsd_set_fh_dentry()
190 data_left -= len; in nfsd_set_fh_dentry()
193 exp = rqst_exp_find(rqstp ? &rqstp->rq_chandle : NULL, in nfsd_set_fh_dentry()
195 fh->fh_fsid_type, fh_fsid(fh)); in nfsd_set_fh_dentry()
202 if (PTR_ERR(exp) == -ENOENT) in nfsd_set_fh_dentry()
208 if (exp->ex_flags & NFSEXP_NOSUBTREECHECK) { in nfsd_set_fh_dentry()
220 error = nfserrno(-ENOMEM); in nfsd_set_fh_dentry()
223 new->cap_effective = in nfsd_set_fh_dentry()
224 cap_raise_nfsd_set(new->cap_effective, in nfsd_set_fh_dentry()
225 new->cap_permitted); in nfsd_set_fh_dentry()
238 fileid_type = fh->fh_fileid_type; in nfsd_set_fh_dentry()
241 dentry = dget(exp->ex_path.dentry); in nfsd_set_fh_dentry()
243 dentry = exportfs_decode_fh_raw(exp->ex_path.mnt, fid, in nfsd_set_fh_dentry()
248 dentry ? PTR_ERR(dentry) : -ESTALE); in nfsd_set_fh_dentry()
250 case -ENOMEM: in nfsd_set_fh_dentry()
251 case -ETIMEDOUT: in nfsd_set_fh_dentry()
254 dentry = ERR_PTR(-ESTALE); in nfsd_set_fh_dentry()
261 if (PTR_ERR(dentry) != -EINVAL) in nfsd_set_fh_dentry()
267 (dentry->d_flags & DCACHE_DISCONNECTED)) { in nfsd_set_fh_dentry()
272 fhp->fh_dentry = dentry; in nfsd_set_fh_dentry()
273 fhp->fh_export = exp; in nfsd_set_fh_dentry()
275 switch (fhp->fh_maxsize) { in nfsd_set_fh_dentry()
277 if (dentry->d_sb->s_export_op->flags & EXPORT_OP_NOATOMIC_ATTR) in nfsd_set_fh_dentry()
278 fhp->fh_no_atomic_attr = true; in nfsd_set_fh_dentry()
279 fhp->fh_64bit_cookies = true; in nfsd_set_fh_dentry()
282 if (dentry->d_sb->s_export_op->flags & EXPORT_OP_NOWCC) in nfsd_set_fh_dentry()
283 fhp->fh_no_wcc = true; in nfsd_set_fh_dentry()
284 fhp->fh_64bit_cookies = true; in nfsd_set_fh_dentry()
285 if (exp->ex_flags & NFSEXP_V4ROOT) in nfsd_set_fh_dentry()
289 fhp->fh_no_wcc = true; in nfsd_set_fh_dentry()
291 fhp->fh_use_wgather = true; in nfsd_set_fh_dentry()
292 if (exp->ex_flags & NFSEXP_V4ROOT) in nfsd_set_fh_dentry()
303 * __fh_verify - filehandle lookup and access checking
309 * @fhp: filehandle to be verified
328 if (!fhp->fh_dentry) { in __fh_verify()
334 dentry = fhp->fh_dentry; in __fh_verify()
335 exp = fhp->fh_export; in __fh_verify()
342 * - fh_verify may be called multiple times with different in __fh_verify()
346 * - in the NFSv4 case, the filehandle may have been filled in __fh_verify()
352 * (for example, if different id-squashing options are in in __fh_verify()
377 if ((access & NFSD_MAY_NLM) && (exp->ex_flags & NFSEXP_NOAUTHNLM)) in __fh_verify()
399 && exp->ex_path.dentry == dentry) in __fh_verify()
406 svc_xprt_set_valid(rqstp->rq_xprt); in __fh_verify()
419 * fh_verify_local - filehandle lookup and access checking
423 * @fhp: filehandle to be verified
442 * fh_verify - filehandle lookup and access checking
444 * @fhp: filehandle to be verified
448 * Look up a dentry from the on-the-wire filehandle, check the client's
456 * up a dentry using the on-the-wire filehandle. Subsequent calls will
471 return __fh_verify(rqstp, SVC_NET(rqstp), &rqstp->rq_cred, in fh_verify()
472 rqstp->rq_client, rqstp->rq_gssclient, in fh_verify()
486 if (dentry != exp->ex_path.dentry) { in _fh_update()
488 (fh_fsid(&fhp->fh_handle) + fhp->fh_handle.fh_size/4 - 1); in _fh_update()
489 int maxsize = (fhp->fh_maxsize - fhp->fh_handle.fh_size)/4; in _fh_update()
490 int fh_flags = (exp->ex_flags & NFSEXP_NOSUBTREECHECK) ? 0 : in _fh_update()
495 fhp->fh_handle.fh_fileid_type = in _fh_update()
497 fhp->fh_handle.fh_size += maxsize * 4; in _fh_update()
499 fhp->fh_handle.fh_fileid_type = FILEID_ROOT; in _fh_update()
505 return exp->ex_path.dentry == exp->ex_path.dentry->d_sb->s_root; in is_root_export()
510 return exp->ex_path.dentry->d_sb; in exp_sb()
517 if (!old_valid_dev(exp_sb(exp)->s_dev)) in fsid_type_ok_for_exp()
522 return exp_sb(exp)->s_type->fs_flags & FS_REQUIRES_DEV; in fsid_type_ok_for_exp()
524 return exp->ex_flags & NFSEXP_FSID; in fsid_type_ok_for_exp()
532 return exp->ex_uuid != NULL; in fsid_type_ok_for_exp()
544 if (ref_fh && ref_fh->fh_export == exp) { in set_version_and_fsid_type()
545 version = ref_fh->fh_handle.fh_version; in set_version_and_fsid_type()
546 fsid_type = ref_fh->fh_handle.fh_fsid_type; in set_version_and_fsid_type()
561 * As the fsid -> filesystem mapping was guided by in set_version_and_fsid_type()
562 * user-space, there is no guarantee that the filesystem in set_version_and_fsid_type()
568 } else if (exp->ex_flags & NFSEXP_FSID) { in set_version_and_fsid_type()
570 } else if (exp->ex_uuid) { in set_version_and_fsid_type()
571 if (fhp->fh_maxsize >= 64) { in set_version_and_fsid_type()
582 } else if (!old_valid_dev(exp_sb(exp)->s_dev)) in set_version_and_fsid_type()
587 fhp->fh_handle.fh_version = version; in set_version_and_fsid_type()
589 fhp->fh_handle.fh_fsid_type = fsid_type; in set_version_and_fsid_type()
597 * if it is non-null and for the same filesystem, then we should compose in fh_compose()
602 dev_t ex_dev = exp_sb(exp)->s_dev; in fh_compose()
606 (long) d_inode(exp->ex_path.dentry)->i_ino, in fh_compose()
608 (inode ? inode->i_ino : 0)); in fh_compose()
617 fhp->fh_no_wcc = ref_fh ? ref_fh->fh_no_wcc : false; in fh_compose()
622 if (fhp->fh_dentry) { in fh_compose()
626 if (fhp->fh_maxsize < NFS_FHSIZE) in fh_compose()
628 fhp->fh_maxsize, in fh_compose()
631 fhp->fh_dentry = dget(dentry); /* our internal copy */ in fh_compose()
632 fhp->fh_export = exp_get(exp); in fh_compose()
634 fhp->fh_handle.fh_size = in fh_compose()
635 key_len(fhp->fh_handle.fh_fsid_type) + 4; in fh_compose()
636 fhp->fh_handle.fh_auth_type = 0; in fh_compose()
638 mk_fsid(fhp->fh_handle.fh_fsid_type, in fh_compose()
639 fh_fsid(&fhp->fh_handle), in fh_compose()
641 d_inode(exp->ex_path.dentry)->i_ino, in fh_compose()
642 exp->ex_fsid, exp->ex_uuid); in fh_compose()
646 if (fhp->fh_handle.fh_fileid_type == FILEID_INVALID) { in fh_compose()
663 if (!fhp->fh_dentry) in fh_update()
666 dentry = fhp->fh_dentry; in fh_update()
669 if (fhp->fh_handle.fh_fileid_type != FILEID_ROOT) in fh_update()
672 _fh_update(fhp, fhp->fh_export, dentry); in fh_update()
673 if (fhp->fh_handle.fh_fileid_type == FILEID_INVALID) in fh_update()
677 printk(KERN_ERR "fh_update: fh not verified!\n"); in fh_update()
686 * fh_getattr - Retrieve attributes on a local file
688 * @stat: Caller-supplied kstat buffer to be filled in
696 .mnt = fhp->fh_export->ex_path.mnt, in fh_getattr()
697 .dentry = fhp->fh_dentry, in fh_getattr()
702 if (S_ISREG(inode->i_mode)) in fh_getattr()
705 if (fhp->fh_maxsize == NFS4_FHSIZE) in fh_getattr()
713 * fh_fill_pre_attrs - Fill in pre-op attributes
719 bool v4 = (fhp->fh_maxsize == NFS4_FHSIZE); in fh_fill_pre_attrs()
723 if (fhp->fh_no_wcc || fhp->fh_pre_saved) in fh_fill_pre_attrs()
731 fhp->fh_pre_change = nfsd4_change_attribute(&stat); in fh_fill_pre_attrs()
733 fhp->fh_pre_mtime = stat.mtime; in fh_fill_pre_attrs()
734 fhp->fh_pre_ctime = stat.ctime; in fh_fill_pre_attrs()
735 fhp->fh_pre_size = stat.size; in fh_fill_pre_attrs()
736 fhp->fh_pre_saved = true; in fh_fill_pre_attrs()
741 * fh_fill_post_attrs - Fill in post-op attributes
747 bool v4 = (fhp->fh_maxsize == NFS4_FHSIZE); in fh_fill_post_attrs()
750 if (fhp->fh_no_wcc) in fh_fill_post_attrs()
753 if (fhp->fh_post_saved) in fh_fill_post_attrs()
756 err = fh_getattr(fhp, &fhp->fh_post_attr); in fh_fill_post_attrs()
760 fhp->fh_post_saved = true; in fh_fill_post_attrs()
762 fhp->fh_post_change = in fh_fill_post_attrs()
763 nfsd4_change_attribute(&fhp->fh_post_attr); in fh_fill_post_attrs()
768 * fh_fill_both_attrs - Fill pre-op and post-op attributes
782 fhp->fh_pre_change = fhp->fh_post_change; in fh_fill_both_attrs()
783 fhp->fh_pre_mtime = fhp->fh_post_attr.mtime; in fh_fill_both_attrs()
784 fhp->fh_pre_ctime = fhp->fh_post_attr.ctime; in fh_fill_both_attrs()
785 fhp->fh_pre_size = fhp->fh_post_attr.size; in fh_fill_both_attrs()
786 fhp->fh_pre_saved = true; in fh_fill_both_attrs()
796 struct dentry * dentry = fhp->fh_dentry; in fh_put()
797 struct svc_export * exp = fhp->fh_export; in fh_put()
799 fhp->fh_dentry = NULL; in fh_put()
806 fhp->fh_export = NULL; in fh_put()
808 fhp->fh_no_wcc = false; in fh_put()
817 struct knfsd_fh *fh = &fhp->fh_handle; in SVCFH_fmt()
820 if (fh->fh_size > 64) in SVCFH_fmt()
821 return "bad-fh"; in SVCFH_fmt()
822 sprintf(buf, "%d: %*ph", fh->fh_size, fh->fh_size, fh->fh_raw); in SVCFH_fmt()
828 if (fhp->fh_handle.fh_version != 1) in fsid_source()
830 switch(fhp->fh_handle.fh_fsid_type) { in fsid_source()
834 if (exp_sb(fhp->fh_export)->s_type->fs_flags & FS_REQUIRES_DEV) in fsid_source()
838 if (fhp->fh_export->ex_flags & NFSEXP_FSID) in fsid_source()
847 if (fhp->fh_export->ex_flags & NFSEXP_FSID) in fsid_source()
849 if (fhp->fh_export->ex_uuid) in fsid_source()
855 * nfsd4_change_attribute - Generate an NFSv4 change_attribute value
860 * Returns an unsigned 64-bit changeid4 value (RFC 8881 Section 3.2).
882 if (stat->result_mask & STATX_CHANGE_COOKIE) { in nfsd4_change_attribute()
883 chattr = stat->change_cookie; in nfsd4_change_attribute()
884 if (S_ISREG(stat->mode) && in nfsd4_change_attribute()
885 !(stat->attributes & STATX_ATTR_CHANGE_MONOTONIC)) { in nfsd4_change_attribute()
886 chattr += (u64)stat->ctime.tv_sec << 30; in nfsd4_change_attribute()
887 chattr += stat->ctime.tv_nsec; in nfsd4_change_attribute()
890 chattr = time_to_chattr(&stat->ctime); in nfsd4_change_attribute()