Lines Matching +full:pre +full:- +full:verified
1 // SPDX-License-Identifier: GPL-2.0
7 * Extensive rewrite by Neil Brown <[email protected]> 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()
236 fileid_type = fh->fh_fileid_type; in nfsd_set_fh_dentry()
239 dentry = dget(exp->ex_path.dentry); in nfsd_set_fh_dentry()
241 dentry = exportfs_decode_fh_raw(exp->ex_path.mnt, fid, in nfsd_set_fh_dentry()
246 dentry ? PTR_ERR(dentry) : -ESTALE); in nfsd_set_fh_dentry()
248 case -ENOMEM: in nfsd_set_fh_dentry()
249 case -ETIMEDOUT: in nfsd_set_fh_dentry()
252 dentry = ERR_PTR(-ESTALE); in nfsd_set_fh_dentry()
259 if (PTR_ERR(dentry) != -EINVAL) in nfsd_set_fh_dentry()
265 (dentry->d_flags & DCACHE_DISCONNECTED)) { in nfsd_set_fh_dentry()
270 fhp->fh_dentry = dentry; in nfsd_set_fh_dentry()
271 fhp->fh_export = exp; in nfsd_set_fh_dentry()
273 switch (fhp->fh_maxsize) { in nfsd_set_fh_dentry()
275 if (dentry->d_sb->s_export_op->flags & EXPORT_OP_NOATOMIC_ATTR) in nfsd_set_fh_dentry()
276 fhp->fh_no_atomic_attr = true; in nfsd_set_fh_dentry()
277 fhp->fh_64bit_cookies = true; in nfsd_set_fh_dentry()
280 if (dentry->d_sb->s_export_op->flags & EXPORT_OP_NOWCC) in nfsd_set_fh_dentry()
281 fhp->fh_no_wcc = true; in nfsd_set_fh_dentry()
282 fhp->fh_64bit_cookies = true; in nfsd_set_fh_dentry()
283 if (exp->ex_flags & NFSEXP_V4ROOT) in nfsd_set_fh_dentry()
287 fhp->fh_no_wcc = true; in nfsd_set_fh_dentry()
289 fhp->fh_use_wgather = true; in nfsd_set_fh_dentry()
290 if (exp->ex_flags & NFSEXP_V4ROOT) in nfsd_set_fh_dentry()
301 * __fh_verify - filehandle lookup and access checking
307 * @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()
365 if ((access & NFSD_MAY_NLM) && (exp->ex_flags & NFSEXP_NOAUTHNLM)) in __fh_verify()
377 && exp->ex_path.dentry == dentry) in __fh_verify()
385 svc_xprt_set_valid(rqstp->rq_xprt); in __fh_verify()
397 * fh_verify_local - filehandle lookup and access checking
401 * @fhp: filehandle to be verified
420 * fh_verify - filehandle lookup and access checking
422 * @fhp: filehandle to be verified
426 * Look up a dentry from the on-the-wire filehandle, check the client's
434 * up a dentry using the on-the-wire filehandle. Subsequent calls will
449 return __fh_verify(rqstp, SVC_NET(rqstp), &rqstp->rq_cred, in fh_verify()
450 rqstp->rq_client, rqstp->rq_gssclient, in fh_verify()
464 if (dentry != exp->ex_path.dentry) { in _fh_update()
466 (fhp->fh_handle.fh_fsid + fhp->fh_handle.fh_size/4 - 1); in _fh_update()
467 int maxsize = (fhp->fh_maxsize - fhp->fh_handle.fh_size)/4; in _fh_update()
468 int fh_flags = (exp->ex_flags & NFSEXP_NOSUBTREECHECK) ? 0 : in _fh_update()
473 fhp->fh_handle.fh_fileid_type = in _fh_update()
475 fhp->fh_handle.fh_size += maxsize * 4; in _fh_update()
477 fhp->fh_handle.fh_fileid_type = FILEID_ROOT; in _fh_update()
483 return exp->ex_path.dentry == exp->ex_path.dentry->d_sb->s_root; in is_root_export()
488 return exp->ex_path.dentry->d_sb; in exp_sb()
495 if (!old_valid_dev(exp_sb(exp)->s_dev)) in fsid_type_ok_for_exp()
500 return exp_sb(exp)->s_type->fs_flags & FS_REQUIRES_DEV; in fsid_type_ok_for_exp()
502 return exp->ex_flags & NFSEXP_FSID; in fsid_type_ok_for_exp()
510 return exp->ex_uuid != NULL; in fsid_type_ok_for_exp()
522 if (ref_fh && ref_fh->fh_export == exp) { in set_version_and_fsid_type()
523 version = ref_fh->fh_handle.fh_version; in set_version_and_fsid_type()
524 fsid_type = ref_fh->fh_handle.fh_fsid_type; in set_version_and_fsid_type()
539 * As the fsid -> filesystem mapping was guided by in set_version_and_fsid_type()
540 * user-space, there is no guarantee that the filesystem in set_version_and_fsid_type()
546 } else if (exp->ex_flags & NFSEXP_FSID) { in set_version_and_fsid_type()
548 } else if (exp->ex_uuid) { in set_version_and_fsid_type()
549 if (fhp->fh_maxsize >= 64) { in set_version_and_fsid_type()
560 } else if (!old_valid_dev(exp_sb(exp)->s_dev)) in set_version_and_fsid_type()
565 fhp->fh_handle.fh_version = version; in set_version_and_fsid_type()
567 fhp->fh_handle.fh_fsid_type = fsid_type; in set_version_and_fsid_type()
575 * if it is non-null and for the same filesystem, then we should compose in fh_compose()
580 dev_t ex_dev = exp_sb(exp)->s_dev; in fh_compose()
584 (long) d_inode(exp->ex_path.dentry)->i_ino, in fh_compose()
586 (inode ? inode->i_ino : 0)); in fh_compose()
595 fhp->fh_no_wcc = ref_fh ? ref_fh->fh_no_wcc : false; in fh_compose()
600 if (fhp->fh_dentry) { in fh_compose()
604 if (fhp->fh_maxsize < NFS_FHSIZE) in fh_compose()
606 fhp->fh_maxsize, in fh_compose()
609 fhp->fh_dentry = dget(dentry); /* our internal copy */ in fh_compose()
610 fhp->fh_export = exp_get(exp); in fh_compose()
612 fhp->fh_handle.fh_size = in fh_compose()
613 key_len(fhp->fh_handle.fh_fsid_type) + 4; in fh_compose()
614 fhp->fh_handle.fh_auth_type = 0; in fh_compose()
616 mk_fsid(fhp->fh_handle.fh_fsid_type, in fh_compose()
617 fhp->fh_handle.fh_fsid, in fh_compose()
619 d_inode(exp->ex_path.dentry)->i_ino, in fh_compose()
620 exp->ex_fsid, exp->ex_uuid); in fh_compose()
624 if (fhp->fh_handle.fh_fileid_type == FILEID_INVALID) { in fh_compose()
641 if (!fhp->fh_dentry) in fh_update()
644 dentry = fhp->fh_dentry; in fh_update()
647 if (fhp->fh_handle.fh_fileid_type != FILEID_ROOT) in fh_update()
650 _fh_update(fhp, fhp->fh_export, dentry); in fh_update()
651 if (fhp->fh_handle.fh_fileid_type == FILEID_INVALID) in fh_update()
655 printk(KERN_ERR "fh_update: fh not verified!\n"); in fh_update()
664 * fh_fill_pre_attrs - Fill in pre-op attributes
670 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()
682 fhp->fh_pre_change = nfsd4_change_attribute(&stat); in fh_fill_pre_attrs()
684 fhp->fh_pre_mtime = stat.mtime; in fh_fill_pre_attrs()
685 fhp->fh_pre_ctime = stat.ctime; in fh_fill_pre_attrs()
686 fhp->fh_pre_size = stat.size; in fh_fill_pre_attrs()
687 fhp->fh_pre_saved = true; in fh_fill_pre_attrs()
692 * fh_fill_post_attrs - Fill in post-op attributes
698 bool v4 = (fhp->fh_maxsize == NFS4_FHSIZE); in fh_fill_post_attrs()
701 if (fhp->fh_no_wcc) in fh_fill_post_attrs()
704 if (fhp->fh_post_saved) in fh_fill_post_attrs()
707 err = fh_getattr(fhp, &fhp->fh_post_attr); in fh_fill_post_attrs()
711 fhp->fh_post_saved = true; in fh_fill_post_attrs()
713 fhp->fh_post_change = in fh_fill_post_attrs()
714 nfsd4_change_attribute(&fhp->fh_post_attr); in fh_fill_post_attrs()
719 * fh_fill_both_attrs - Fill pre-op and post-op attributes
733 fhp->fh_pre_change = fhp->fh_post_change; in fh_fill_both_attrs()
734 fhp->fh_pre_mtime = fhp->fh_post_attr.mtime; in fh_fill_both_attrs()
735 fhp->fh_pre_ctime = fhp->fh_post_attr.ctime; in fh_fill_both_attrs()
736 fhp->fh_pre_size = fhp->fh_post_attr.size; in fh_fill_both_attrs()
737 fhp->fh_pre_saved = true; in fh_fill_both_attrs()
747 struct dentry * dentry = fhp->fh_dentry; in fh_put()
748 struct svc_export * exp = fhp->fh_export; in fh_put()
750 fhp->fh_dentry = NULL; in fh_put()
757 fhp->fh_export = NULL; in fh_put()
759 fhp->fh_no_wcc = false; in fh_put()
768 struct knfsd_fh *fh = &fhp->fh_handle; in SVCFH_fmt()
771 if (fh->fh_size > 64) in SVCFH_fmt()
772 return "bad-fh"; in SVCFH_fmt()
773 sprintf(buf, "%d: %*ph", fh->fh_size, fh->fh_size, fh->fh_raw); in SVCFH_fmt()
779 if (fhp->fh_handle.fh_version != 1) in fsid_source()
781 switch(fhp->fh_handle.fh_fsid_type) { in fsid_source()
785 if (exp_sb(fhp->fh_export)->s_type->fs_flags & FS_REQUIRES_DEV) in fsid_source()
789 if (fhp->fh_export->ex_flags & NFSEXP_FSID) in fsid_source()
798 if (fhp->fh_export->ex_flags & NFSEXP_FSID) in fsid_source()
800 if (fhp->fh_export->ex_uuid) in fsid_source()
806 * nfsd4_change_attribute - Generate an NFSv4 change_attribute value
811 * Returns an unsigned 64-bit changeid4 value (RFC 8881 Section 3.2).
833 if (stat->result_mask & STATX_CHANGE_COOKIE) { in nfsd4_change_attribute()
834 chattr = stat->change_cookie; in nfsd4_change_attribute()
835 if (S_ISREG(stat->mode) && in nfsd4_change_attribute()
836 !(stat->attributes & STATX_ATTR_CHANGE_MONOTONIC)) { in nfsd4_change_attribute()
837 chattr += (u64)stat->ctime.tv_sec << 30; in nfsd4_change_attribute()
838 chattr += stat->ctime.tv_nsec; in nfsd4_change_attribute()
841 chattr = time_to_chattr(&stat->ctime); in nfsd4_change_attribute()