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()
68 umode_t mode = d_inode(dentry)->i_mode & S_IFMT; in nfsd_mode_check()
83 if (rqstp->rq_vers == 4 && mode == S_IFLNK) in nfsd_mode_check()
97 if (rqstp->rq_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()
122 if (!(exp->ex_flags & NFSEXP_V4ROOT)) in check_pseudo_root()
125 * v2/v3 clients have no need for the V4ROOT export--they use in check_pseudo_root()
127 * in v4-specific code, in which case v2/v3 clients could bypass in check_pseudo_root()
144 if (unlikely(dentry != exp->ex_path.dentry)) in check_pseudo_root()
156 struct knfsd_fh *fh = &fhp->fh_handle; in nfsd_set_fh_dentry()
161 int data_left = fh->fh_size/4; in nfsd_set_fh_dentry()
166 if (rqstp->rq_vers > 2) in nfsd_set_fh_dentry()
168 if (rqstp->rq_vers == 4 && fh->fh_size == 0) in nfsd_set_fh_dentry()
171 if (fh->fh_version != 1) in nfsd_set_fh_dentry()
174 if (--data_left < 0) in nfsd_set_fh_dentry()
176 if (fh->fh_auth_type != 0) in nfsd_set_fh_dentry()
178 len = key_len(fh->fh_fsid_type) / 4; in nfsd_set_fh_dentry()
181 if (fh->fh_fsid_type == FSID_MAJOR_MINOR) { in nfsd_set_fh_dentry()
184 fh->fh_fsid_type = FSID_ENCODE_DEV; in nfsd_set_fh_dentry()
186 * struct knfsd_fh uses host-endian fields, which are in nfsd_set_fh_dentry()
187 * sometimes used to hold net-endian values. This in nfsd_set_fh_dentry()
191 fh->fh_fsid[0] = new_encode_dev(MKDEV(ntohl((__force __be32)fh->fh_fsid[0]), in nfsd_set_fh_dentry()
192 ntohl((__force __be32)fh->fh_fsid[1]))); in nfsd_set_fh_dentry()
193 fh->fh_fsid[1] = fh->fh_fsid[2]; in nfsd_set_fh_dentry()
195 data_left -= len; in nfsd_set_fh_dentry()
198 exp = rqst_exp_find(rqstp, fh->fh_fsid_type, fh->fh_fsid); in nfsd_set_fh_dentry()
199 fid = (struct fid *)(fh->fh_fsid + len); in nfsd_set_fh_dentry()
205 if (PTR_ERR(exp) == -ENOENT) in nfsd_set_fh_dentry()
211 if (exp->ex_flags & NFSEXP_NOSUBTREECHECK) { in nfsd_set_fh_dentry()
223 error = nfserrno(-ENOMEM); in nfsd_set_fh_dentry()
226 new->cap_effective = in nfsd_set_fh_dentry()
227 cap_raise_nfsd_set(new->cap_effective, in nfsd_set_fh_dentry()
228 new->cap_permitted); in nfsd_set_fh_dentry()
241 if (rqstp->rq_vers > 2) in nfsd_set_fh_dentry()
244 fileid_type = fh->fh_fileid_type; in nfsd_set_fh_dentry()
247 dentry = dget(exp->ex_path.dentry); in nfsd_set_fh_dentry()
249 dentry = exportfs_decode_fh_raw(exp->ex_path.mnt, fid, in nfsd_set_fh_dentry()
254 dentry ? PTR_ERR(dentry) : -ESTALE); in nfsd_set_fh_dentry()
256 case -ENOMEM: in nfsd_set_fh_dentry()
257 case -ETIMEDOUT: in nfsd_set_fh_dentry()
260 dentry = ERR_PTR(-ESTALE); in nfsd_set_fh_dentry()
267 if (PTR_ERR(dentry) != -EINVAL) in nfsd_set_fh_dentry()
273 (dentry->d_flags & DCACHE_DISCONNECTED)) { in nfsd_set_fh_dentry()
278 fhp->fh_dentry = dentry; in nfsd_set_fh_dentry()
279 fhp->fh_export = exp; in nfsd_set_fh_dentry()
281 switch (rqstp->rq_vers) { in nfsd_set_fh_dentry()
283 if (dentry->d_sb->s_export_op->flags & EXPORT_OP_NOATOMIC_ATTR) in nfsd_set_fh_dentry()
284 fhp->fh_no_atomic_attr = true; in nfsd_set_fh_dentry()
287 if (dentry->d_sb->s_export_op->flags & EXPORT_OP_NOWCC) in nfsd_set_fh_dentry()
288 fhp->fh_no_wcc = true; in nfsd_set_fh_dentry()
291 fhp->fh_no_wcc = true; in nfsd_set_fh_dentry()
301 * fh_verify - filehandle lookup and access checking
303 * @fhp: filehandle to be verified
307 * Look up a dentry from the on-the-wire filehandle, check the client's
315 * up a dentry using the on-the-wire filehandle. Subsequent calls will
335 if (!fhp->fh_dentry) { in fh_verify()
340 dentry = fhp->fh_dentry; in fh_verify()
341 exp = fhp->fh_export; in fh_verify()
348 * - fh_verify may be called multiple times with different in fh_verify()
352 * - in the NFSv4 case, the filehandle may have been filled in fh_verify()
358 * (for example, if different id-squashing options are in in fh_verify()
386 && exp->ex_path.dentry == dentry) in fh_verify()
414 if (dentry != exp->ex_path.dentry) { in _fh_update()
416 (fhp->fh_handle.fh_fsid + fhp->fh_handle.fh_size/4 - 1); in _fh_update()
417 int maxsize = (fhp->fh_maxsize - fhp->fh_handle.fh_size)/4; in _fh_update()
418 int fh_flags = (exp->ex_flags & NFSEXP_NOSUBTREECHECK) ? 0 : in _fh_update()
423 fhp->fh_handle.fh_fileid_type = in _fh_update()
425 fhp->fh_handle.fh_size += maxsize * 4; in _fh_update()
427 fhp->fh_handle.fh_fileid_type = FILEID_ROOT; in _fh_update()
433 return exp->ex_path.dentry == exp->ex_path.dentry->d_sb->s_root; in is_root_export()
438 return exp->ex_path.dentry->d_sb; in exp_sb()
445 if (!old_valid_dev(exp_sb(exp)->s_dev)) in fsid_type_ok_for_exp()
450 return exp_sb(exp)->s_type->fs_flags & FS_REQUIRES_DEV; in fsid_type_ok_for_exp()
452 return exp->ex_flags & NFSEXP_FSID; in fsid_type_ok_for_exp()
460 return exp->ex_uuid != NULL; in fsid_type_ok_for_exp()
472 if (ref_fh && ref_fh->fh_export == exp) { in set_version_and_fsid_type()
473 version = ref_fh->fh_handle.fh_version; in set_version_and_fsid_type()
474 fsid_type = ref_fh->fh_handle.fh_fsid_type; in set_version_and_fsid_type()
489 * As the fsid -> filesystem mapping was guided by in set_version_and_fsid_type()
490 * user-space, there is no guarantee that the filesystem in set_version_and_fsid_type()
496 } else if (exp->ex_flags & NFSEXP_FSID) { in set_version_and_fsid_type()
498 } else if (exp->ex_uuid) { in set_version_and_fsid_type()
499 if (fhp->fh_maxsize >= 64) { in set_version_and_fsid_type()
510 } else if (!old_valid_dev(exp_sb(exp)->s_dev)) in set_version_and_fsid_type()
515 fhp->fh_handle.fh_version = version; in set_version_and_fsid_type()
517 fhp->fh_handle.fh_fsid_type = fsid_type; in set_version_and_fsid_type()
525 * if it is non-null and for the same filesystem, then we should compose in fh_compose()
530 dev_t ex_dev = exp_sb(exp)->s_dev; in fh_compose()
534 (long) d_inode(exp->ex_path.dentry)->i_ino, in fh_compose()
536 (inode ? inode->i_ino : 0)); in fh_compose()
545 fhp->fh_no_wcc = ref_fh ? ref_fh->fh_no_wcc : false; in fh_compose()
550 if (fhp->fh_dentry) { in fh_compose()
554 if (fhp->fh_maxsize < NFS_FHSIZE) in fh_compose()
556 fhp->fh_maxsize, in fh_compose()
559 fhp->fh_dentry = dget(dentry); /* our internal copy */ in fh_compose()
560 fhp->fh_export = exp_get(exp); in fh_compose()
562 fhp->fh_handle.fh_size = in fh_compose()
563 key_len(fhp->fh_handle.fh_fsid_type) + 4; in fh_compose()
564 fhp->fh_handle.fh_auth_type = 0; in fh_compose()
566 mk_fsid(fhp->fh_handle.fh_fsid_type, in fh_compose()
567 fhp->fh_handle.fh_fsid, in fh_compose()
569 d_inode(exp->ex_path.dentry)->i_ino, in fh_compose()
570 exp->ex_fsid, exp->ex_uuid); in fh_compose()
574 if (fhp->fh_handle.fh_fileid_type == FILEID_INVALID) { in fh_compose()
591 if (!fhp->fh_dentry) in fh_update()
594 dentry = fhp->fh_dentry; in fh_update()
597 if (fhp->fh_handle.fh_fileid_type != FILEID_ROOT) in fh_update()
600 _fh_update(fhp, fhp->fh_export, dentry); in fh_update()
601 if (fhp->fh_handle.fh_fileid_type == FILEID_INVALID) in fh_update()
605 printk(KERN_ERR "fh_update: fh not verified!\n"); in fh_update()
614 * fh_fill_pre_attrs - Fill in pre-op attributes
620 bool v4 = (fhp->fh_maxsize == NFS4_FHSIZE); in fh_fill_pre_attrs()
625 if (fhp->fh_no_wcc || fhp->fh_pre_saved) in fh_fill_pre_attrs()
628 inode = d_inode(fhp->fh_dentry); in fh_fill_pre_attrs()
634 fhp->fh_pre_change = nfsd4_change_attribute(&stat, inode); in fh_fill_pre_attrs()
636 fhp->fh_pre_mtime = stat.mtime; in fh_fill_pre_attrs()
637 fhp->fh_pre_ctime = stat.ctime; in fh_fill_pre_attrs()
638 fhp->fh_pre_size = stat.size; in fh_fill_pre_attrs()
639 fhp->fh_pre_saved = true; in fh_fill_pre_attrs()
644 * fh_fill_post_attrs - Fill in post-op attributes
650 bool v4 = (fhp->fh_maxsize == NFS4_FHSIZE); in fh_fill_post_attrs()
651 struct inode *inode = d_inode(fhp->fh_dentry); in fh_fill_post_attrs()
654 if (fhp->fh_no_wcc) in fh_fill_post_attrs()
657 if (fhp->fh_post_saved) in fh_fill_post_attrs()
660 err = fh_getattr(fhp, &fhp->fh_post_attr); in fh_fill_post_attrs()
664 fhp->fh_post_saved = true; in fh_fill_post_attrs()
666 fhp->fh_post_change = in fh_fill_post_attrs()
667 nfsd4_change_attribute(&fhp->fh_post_attr, inode); in fh_fill_post_attrs()
672 * fh_fill_both_attrs - Fill pre-op and post-op attributes
686 fhp->fh_pre_change = fhp->fh_post_change; in fh_fill_both_attrs()
687 fhp->fh_pre_mtime = fhp->fh_post_attr.mtime; in fh_fill_both_attrs()
688 fhp->fh_pre_ctime = fhp->fh_post_attr.ctime; in fh_fill_both_attrs()
689 fhp->fh_pre_size = fhp->fh_post_attr.size; in fh_fill_both_attrs()
690 fhp->fh_pre_saved = true; in fh_fill_both_attrs()
700 struct dentry * dentry = fhp->fh_dentry; in fh_put()
701 struct svc_export * exp = fhp->fh_export; in fh_put()
703 fhp->fh_dentry = NULL; in fh_put()
710 fhp->fh_export = NULL; in fh_put()
712 fhp->fh_no_wcc = false; in fh_put()
721 struct knfsd_fh *fh = &fhp->fh_handle; in SVCFH_fmt()
724 if (fh->fh_size < 0 || fh->fh_size> 64) in SVCFH_fmt()
725 return "bad-fh"; in SVCFH_fmt()
726 sprintf(buf, "%d: %*ph", fh->fh_size, fh->fh_size, fh->fh_raw); in SVCFH_fmt()
732 if (fhp->fh_handle.fh_version != 1) in fsid_source()
734 switch(fhp->fh_handle.fh_fsid_type) { in fsid_source()
738 if (exp_sb(fhp->fh_export)->s_type->fs_flags & FS_REQUIRES_DEV) in fsid_source()
742 if (fhp->fh_export->ex_flags & NFSEXP_FSID) in fsid_source()
751 if (fhp->fh_export->ex_flags & NFSEXP_FSID) in fsid_source()
753 if (fhp->fh_export->ex_uuid) in fsid_source()
779 if (stat->result_mask & STATX_CHANGE_COOKIE) { in nfsd4_change_attribute()
780 chattr = stat->change_cookie; in nfsd4_change_attribute()
781 if (S_ISREG(inode->i_mode) && in nfsd4_change_attribute()
782 !(stat->attributes & STATX_ATTR_CHANGE_MONOTONIC)) { in nfsd4_change_attribute()
783 chattr += (u64)stat->ctime.tv_sec << 30; in nfsd4_change_attribute()
784 chattr += stat->ctime.tv_nsec; in nfsd4_change_attribute()
787 chattr = time_to_chattr(&stat->ctime); in nfsd4_change_attribute()