Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nfsd: clean up fh_auth usage

Use fh_fsid when reffering to the fsid part of the filehandle. The
variable length auth field envisioned in nfsfh wasn't ever implemented.
Also clean up some lose ends around this and document the file handle
format better.

Btw, why do we even export nfsfh.h to userspace? The file handle very
much is kernel private, and nothing in nfs-utils include the header
either.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>

authored by

Christoph Hellwig and committed by
J. Bruce Fields
5409e46f ecc7455d

+16 -36
+9 -11
fs/nfsd/nfsfh.c
··· 169 169 data_left -= len; 170 170 if (data_left < 0) 171 171 return error; 172 - exp = rqst_exp_find(rqstp, fh->fh_fsid_type, fh->fh_auth); 173 - fid = (struct fid *)(fh->fh_auth + len); 172 + exp = rqst_exp_find(rqstp, fh->fh_fsid_type, fh->fh_fsid); 173 + fid = (struct fid *)(fh->fh_fsid + len); 174 174 } else { 175 175 __u32 tfh[2]; 176 176 dev_t xdev; ··· 385 385 { 386 386 if (dentry != exp->ex_path.dentry) { 387 387 struct fid *fid = (struct fid *) 388 - (fhp->fh_handle.fh_auth + fhp->fh_handle.fh_size/4 - 1); 388 + (fhp->fh_handle.fh_fsid + fhp->fh_handle.fh_size/4 - 1); 389 389 int maxsize = (fhp->fh_maxsize - fhp->fh_handle.fh_size)/4; 390 390 int subtreecheck = !(exp->ex_flags & NFSEXP_NOSUBTREECHECK); 391 391 ··· 513 513 */ 514 514 515 515 struct inode * inode = dentry->d_inode; 516 - __u32 *datap; 517 516 dev_t ex_dev = exp_sb(exp)->s_dev; 518 517 519 518 dprintk("nfsd: fh_compose(exp %02x:%02x/%ld %pd2, ino=%ld)\n", ··· 556 557 if (inode) 557 558 _fh_update_old(dentry, exp, &fhp->fh_handle); 558 559 } else { 559 - int len; 560 + fhp->fh_handle.fh_size = 561 + key_len(fhp->fh_handle.fh_fsid_type) + 4; 560 562 fhp->fh_handle.fh_auth_type = 0; 561 - datap = fhp->fh_handle.fh_auth+0; 562 - mk_fsid(fhp->fh_handle.fh_fsid_type, datap, ex_dev, 563 + 564 + mk_fsid(fhp->fh_handle.fh_fsid_type, 565 + fhp->fh_handle.fh_fsid, 566 + ex_dev, 563 567 exp->ex_path.dentry->d_inode->i_ino, 564 568 exp->ex_fsid, exp->ex_uuid); 565 - 566 - len = key_len(fhp->fh_handle.fh_fsid_type); 567 - datap += len/4; 568 - fhp->fh_handle.fh_size = 4 + len; 569 569 570 570 if (inode) 571 571 _fh_update(fhp, exp, dentry);
+7 -25
include/uapi/linux/nfsd/nfsfh.h
··· 1 1 /* 2 - * include/linux/nfsd/nfsfh.h 3 - * 4 2 * This file describes the layout of the file handles as passed 5 3 * over the wire. 6 - * 7 - * Earlier versions of knfsd used to sign file handles using keyed MD5 8 - * or SHA. I've removed this code, because it doesn't give you more 9 - * security than blocking external access to port 2049 on your firewall. 10 4 * 11 5 * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de> 12 6 */ ··· 31 37 }; 32 38 33 39 /* 34 - * This is the new flexible, extensible style NFSv2/v3 file handle. 40 + * This is the new flexible, extensible style NFSv2/v3/v4 file handle. 35 41 * by Neil Brown <neilb@cse.unsw.edu.au> - March 2000 36 42 * 37 43 * The file handle starts with a sequence of four-byte words. ··· 41 47 * 42 48 * All four-byte values are in host-byte-order. 43 49 * 44 - * The auth_type field specifies how the filehandle can be authenticated 45 - * This might allow a file to be confirmed to be in a writable part of a 46 - * filetree without checking the path from it up to the root. 47 - * Current values: 48 - * 0 - No authentication. fb_auth is 0 bytes long 49 - * Possible future values: 50 - * 1 - 4 bytes taken from MD5 hash of the remainer of the file handle 51 - * prefixed by a secret and with the important export flags. 50 + * The auth_type field is deprecated and must be set to 0. 52 51 * 53 52 * The fsid_type identifies how the filesystem (or export point) is 54 53 * encoded. ··· 58 71 * 7 - 8 byte inode number and 16 byte uuid 59 72 * 60 73 * The fileid_type identified how the file within the filesystem is encoded. 61 - * This is (will be) passed to, and set by, the underlying filesystem if it supports 62 - * filehandle operations. The filesystem must not use the value '0' or '0xff' and may 63 - * only use the values 1 and 2 as defined below: 64 - * Current values: 65 - * 0 - The root, or export point, of the filesystem. fb_fileid is 0 bytes. 66 - * 1 - 32bit inode number, 32 bit generation number. 67 - * 2 - 32bit inode number, 32 bit generation number, 32 bit parent directory inode number. 68 - * 74 + * The values for this field are filesystem specific, exccept that 75 + * filesystems must not use the values '0' or '0xff'. 'See enum fid_type' 76 + * in include/linux/exportfs.h for currently registered values. 69 77 */ 70 78 struct nfs_fhbase_new { 71 79 __u8 fb_version; /* == 1, even => nfs_fhbase_old */ ··· 96 114 #define fh_fsid_type fh_base.fh_new.fb_fsid_type 97 115 #define fh_auth_type fh_base.fh_new.fb_auth_type 98 116 #define fh_fileid_type fh_base.fh_new.fb_fileid_type 99 - #define fh_auth fh_base.fh_new.fb_auth 100 117 #define fh_fsid fh_base.fh_new.fb_auth 101 118 102 - 119 + /* Do not use, provided for userspace compatiblity. */ 120 + #define fh_auth fh_base.fh_new.fb_auth 103 121 104 122 #endif /* _UAPI_LINUX_NFSD_FH_H */