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()
177 fh->fh_fsid_type = FSID_ENCODE_DEV; in nfsd_set_fh_dentry()
179 * struct knfsd_fh uses host-endian fields, which are in nfsd_set_fh_dentry()
180 * sometimes used to hold net-endian values. This in nfsd_set_fh_dentry()
184 fh->fh_fsid[0] = new_encode_dev(MKDEV(ntohl((__force __be32)fh->fh_fsid[0]), in nfsd_set_fh_dentry()
185 ntohl((__force __be32)fh->fh_fsid[1]))); in nfsd_set_fh_dentry()
186 fh->fh_fsid[1] = fh->fh_fsid[2]; in nfsd_set_fh_dentry()
188 data_left -= len; in nfsd_set_fh_dentry()
191 exp = rqst_exp_find(rqstp ? &rqstp->rq_chandle : NULL, in nfsd_set_fh_dentry()
193 fh->fh_fsid_type, fh->fh_fsid); in nfsd_set_fh_dentry()
194 fid = (struct fid *)(fh->fh_fsid + len); in nfsd_set_fh_dentry()
200 if (PTR_ERR(exp) == -ENOENT) in nfsd_set_fh_dentry()
206 if (exp->ex_flags & NFSEXP_NOSUBTREECHECK) { in nfsd_set_fh_dentry()
218 error = nfserrno(-ENOMEM); in nfsd_set_fh_dentry()
221 new->cap_effective = in nfsd_set_fh_dentry()
222 cap_raise_nfsd_set(new->cap_effective, in nfsd_set_fh_dentry()
223 new->cap_permitted); in nfsd_set_fh_dentry()
237 fileid_type = fh->fh_fileid_type; in nfsd_set_fh_dentry()
240 dentry = dget(exp->ex_path.dentry); in nfsd_set_fh_dentry()
242 dentry = exportfs_decode_fh_raw(exp->ex_path.mnt, fid, in nfsd_set_fh_dentry()
247 dentry ? PTR_ERR(dentry) : -ESTALE); in nfsd_set_fh_dentry()
249 case -ENOMEM: in nfsd_set_fh_dentry()
250 case -ETIMEDOUT: in nfsd_set_fh_dentry()
253 dentry = ERR_PTR(-ESTALE); in nfsd_set_fh_dentry()
260 if (PTR_ERR(dentry) != -EINVAL) in nfsd_set_fh_dentry()
266 (dentry->d_flags & DCACHE_DISCONNECTED)) { in nfsd_set_fh_dentry()
271 fhp->fh_dentry = dentry; in nfsd_set_fh_dentry()
272 fhp->fh_export = exp; in nfsd_set_fh_dentry()
274 switch (fhp->fh_maxsize) { in nfsd_set_fh_dentry()
276 if (dentry->d_sb->s_export_op->flags & EXPORT_OP_NOATOMIC_ATTR) in nfsd_set_fh_dentry()
277 fhp->fh_no_atomic_attr = true; in nfsd_set_fh_dentry()
278 fhp->fh_64bit_cookies = true; in nfsd_set_fh_dentry()
281 if (dentry->d_sb->s_export_op->flags & EXPORT_OP_NOWCC) in nfsd_set_fh_dentry()
282 fhp->fh_no_wcc = true; in nfsd_set_fh_dentry()
283 fhp->fh_64bit_cookies = true; in nfsd_set_fh_dentry()
284 if (exp->ex_flags & NFSEXP_V4ROOT) in nfsd_set_fh_dentry()
288 fhp->fh_no_wcc = true; in nfsd_set_fh_dentry()
290 fhp->fh_use_wgather = true; in nfsd_set_fh_dentry()
291 if (exp->ex_flags & NFSEXP_V4ROOT) in nfsd_set_fh_dentry()
302 * __fh_verify - filehandle lookup and access checking
308 * @fhp: filehandle to be verified
326 if (!fhp->fh_dentry) { in __fh_verify()
332 dentry = fhp->fh_dentry; in __fh_verify()
333 exp = fhp->fh_export; in __fh_verify()
340 * - fh_verify may be called multiple times with different in __fh_verify()
344 * - in the NFSv4 case, the filehandle may have been filled in __fh_verify()
350 * (for example, if different id-squashing options are in in __fh_verify()
378 && exp->ex_path.dentry == dentry) in __fh_verify()
396 * fh_verify_local - filehandle lookup and access checking
400 * @fhp: filehandle to be verified
419 * fh_verify - filehandle lookup and access checking
421 * @fhp: filehandle to be verified
425 * Look up a dentry from the on-the-wire filehandle, check the client's
433 * up a dentry using the on-the-wire filehandle. Subsequent calls will
448 return __fh_verify(rqstp, SVC_NET(rqstp), &rqstp->rq_cred, in fh_verify()
449 rqstp->rq_client, rqstp->rq_gssclient, in fh_verify()
463 if (dentry != exp->ex_path.dentry) { in _fh_update()
465 (fhp->fh_handle.fh_fsid + fhp->fh_handle.fh_size/4 - 1); in _fh_update()
466 int maxsize = (fhp->fh_maxsize - fhp->fh_handle.fh_size)/4; in _fh_update()
467 int fh_flags = (exp->ex_flags & NFSEXP_NOSUBTREECHECK) ? 0 : in _fh_update()
472 fhp->fh_handle.fh_fileid_type = in _fh_update()
474 fhp->fh_handle.fh_size += maxsize * 4; in _fh_update()
476 fhp->fh_handle.fh_fileid_type = FILEID_ROOT; in _fh_update()
482 return exp->ex_path.dentry == exp->ex_path.dentry->d_sb->s_root; in is_root_export()
487 return exp->ex_path.dentry->d_sb; in exp_sb()
494 if (!old_valid_dev(exp_sb(exp)->s_dev)) in fsid_type_ok_for_exp()
499 return exp_sb(exp)->s_type->fs_flags & FS_REQUIRES_DEV; in fsid_type_ok_for_exp()
501 return exp->ex_flags & NFSEXP_FSID; in fsid_type_ok_for_exp()
509 return exp->ex_uuid != NULL; in fsid_type_ok_for_exp()
521 if (ref_fh && ref_fh->fh_export == exp) { in set_version_and_fsid_type()
522 version = ref_fh->fh_handle.fh_version; in set_version_and_fsid_type()
523 fsid_type = ref_fh->fh_handle.fh_fsid_type; in set_version_and_fsid_type()
538 * As the fsid -> filesystem mapping was guided by in set_version_and_fsid_type()
539 * user-space, there is no guarantee that the filesystem in set_version_and_fsid_type()
545 } else if (exp->ex_flags & NFSEXP_FSID) { in set_version_and_fsid_type()
547 } else if (exp->ex_uuid) { in set_version_and_fsid_type()
548 if (fhp->fh_maxsize >= 64) { in set_version_and_fsid_type()
559 } else if (!old_valid_dev(exp_sb(exp)->s_dev)) in set_version_and_fsid_type()
564 fhp->fh_handle.fh_version = version; in set_version_and_fsid_type()
566 fhp->fh_handle.fh_fsid_type = fsid_type; in set_version_and_fsid_type()
574 * if it is non-null and for the same filesystem, then we should compose in fh_compose()
579 dev_t ex_dev = exp_sb(exp)->s_dev; in fh_compose()
583 (long) d_inode(exp->ex_path.dentry)->i_ino, in fh_compose()
585 (inode ? inode->i_ino : 0)); in fh_compose()
594 fhp->fh_no_wcc = ref_fh ? ref_fh->fh_no_wcc : false; in fh_compose()
599 if (fhp->fh_dentry) { in fh_compose()
603 if (fhp->fh_maxsize < NFS_FHSIZE) in fh_compose()
605 fhp->fh_maxsize, in fh_compose()
608 fhp->fh_dentry = dget(dentry); /* our internal copy */ in fh_compose()
609 fhp->fh_export = exp_get(exp); in fh_compose()
611 fhp->fh_handle.fh_size = in fh_compose()
612 key_len(fhp->fh_handle.fh_fsid_type) + 4; in fh_compose()
613 fhp->fh_handle.fh_auth_type = 0; in fh_compose()
615 mk_fsid(fhp->fh_handle.fh_fsid_type, in fh_compose()
616 fhp->fh_handle.fh_fsid, in fh_compose()
618 d_inode(exp->ex_path.dentry)->i_ino, in fh_compose()
619 exp->ex_fsid, exp->ex_uuid); in fh_compose()
623 if (fhp->fh_handle.fh_fileid_type == FILEID_INVALID) { in fh_compose()
640 if (!fhp->fh_dentry) in fh_update()
643 dentry = fhp->fh_dentry; in fh_update()
646 if (fhp->fh_handle.fh_fileid_type != FILEID_ROOT) in fh_update()
649 _fh_update(fhp, fhp->fh_export, dentry); in fh_update()
650 if (fhp->fh_handle.fh_fileid_type == FILEID_INVALID) in fh_update()
654 printk(KERN_ERR "fh_update: fh not verified!\n"); in fh_update()
663 * fh_fill_pre_attrs - Fill in pre-op attributes
669 bool v4 = (fhp->fh_maxsize == NFS4_FHSIZE); in fh_fill_pre_attrs()
674 if (fhp->fh_no_wcc || fhp->fh_pre_saved) in fh_fill_pre_attrs()
677 inode = d_inode(fhp->fh_dentry); in fh_fill_pre_attrs()
683 fhp->fh_pre_change = nfsd4_change_attribute(&stat, inode); in fh_fill_pre_attrs()
685 fhp->fh_pre_mtime = stat.mtime; in fh_fill_pre_attrs()
686 fhp->fh_pre_ctime = stat.ctime; in fh_fill_pre_attrs()
687 fhp->fh_pre_size = stat.size; in fh_fill_pre_attrs()
688 fhp->fh_pre_saved = true; in fh_fill_pre_attrs()
693 * fh_fill_post_attrs - Fill in post-op attributes
699 bool v4 = (fhp->fh_maxsize == NFS4_FHSIZE); in fh_fill_post_attrs()
700 struct inode *inode = d_inode(fhp->fh_dentry); in fh_fill_post_attrs()
703 if (fhp->fh_no_wcc) in fh_fill_post_attrs()
706 if (fhp->fh_post_saved) in fh_fill_post_attrs()
709 err = fh_getattr(fhp, &fhp->fh_post_attr); in fh_fill_post_attrs()
713 fhp->fh_post_saved = true; in fh_fill_post_attrs()
715 fhp->fh_post_change = in fh_fill_post_attrs()
716 nfsd4_change_attribute(&fhp->fh_post_attr, inode); in fh_fill_post_attrs()
721 * fh_fill_both_attrs - Fill pre-op and post-op attributes
735 fhp->fh_pre_change = fhp->fh_post_change; in fh_fill_both_attrs()
736 fhp->fh_pre_mtime = fhp->fh_post_attr.mtime; in fh_fill_both_attrs()
737 fhp->fh_pre_ctime = fhp->fh_post_attr.ctime; in fh_fill_both_attrs()
738 fhp->fh_pre_size = fhp->fh_post_attr.size; in fh_fill_both_attrs()
739 fhp->fh_pre_saved = true; in fh_fill_both_attrs()
749 struct dentry * dentry = fhp->fh_dentry; in fh_put()
750 struct svc_export * exp = fhp->fh_export; in fh_put()
752 fhp->fh_dentry = NULL; in fh_put()
759 fhp->fh_export = NULL; in fh_put()
761 fhp->fh_no_wcc = false; in fh_put()
770 struct knfsd_fh *fh = &fhp->fh_handle; in SVCFH_fmt()
773 if (fh->fh_size < 0 || fh->fh_size> 64) in SVCFH_fmt()
774 return "bad-fh"; in SVCFH_fmt()
775 sprintf(buf, "%d: %*ph", fh->fh_size, fh->fh_size, fh->fh_raw); in SVCFH_fmt()
781 if (fhp->fh_handle.fh_version != 1) in fsid_source()
783 switch(fhp->fh_handle.fh_fsid_type) { in fsid_source()
787 if (exp_sb(fhp->fh_export)->s_type->fs_flags & FS_REQUIRES_DEV) in fsid_source()
791 if (fhp->fh_export->ex_flags & NFSEXP_FSID) in fsid_source()
800 if (fhp->fh_export->ex_flags & NFSEXP_FSID) in fsid_source()
802 if (fhp->fh_export->ex_uuid) in fsid_source()
828 if (stat->result_mask & STATX_CHANGE_COOKIE) { in nfsd4_change_attribute()
829 chattr = stat->change_cookie; in nfsd4_change_attribute()
830 if (S_ISREG(inode->i_mode) && in nfsd4_change_attribute()
831 !(stat->attributes & STATX_ATTR_CHANGE_MONOTONIC)) { in nfsd4_change_attribute()
832 chattr += (u64)stat->ctime.tv_sec << 30; in nfsd4_change_attribute()
833 chattr += stat->ctime.tv_nsec; in nfsd4_change_attribute()
836 chattr = time_to_chattr(&stat->ctime); in nfsd4_change_attribute()