summaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4xdr.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2012-06-21 11:18:13 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-06-28 17:20:44 -0400
commit256e48bb473b631fbb5aa03d6ed38c652ad3caa7 (patch)
treef5a7ec0824ef09fcae105556ffecdae00c23a509 /fs/nfs/nfs4xdr.c
parent4517d526c8aa31b5c14165ef180cc19518ff0a35 (diff)
NFSv4: Simplify the GETATTR attribute length calculation
Use the xdr_stream position counter as the basis for the calculation instead of assuming that we can calculate an offset to the start of the iovec. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs4xdr.c')
-rw-r--r--fs/nfs/nfs4xdr.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 2754f7268c1f..93f8bec9f4f3 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -3078,7 +3078,7 @@ out_overflow:
3078 return -EIO; 3078 return -EIO;
3079} 3079}
3080 3080
3081static inline int decode_attr_length(struct xdr_stream *xdr, uint32_t *attrlen, __be32 **savep) 3081static int decode_attr_length(struct xdr_stream *xdr, uint32_t *attrlen, unsigned int *savep)
3082{ 3082{
3083 __be32 *p; 3083 __be32 *p;
3084 3084
@@ -3086,7 +3086,7 @@ static inline int decode_attr_length(struct xdr_stream *xdr, uint32_t *attrlen,
3086 if (unlikely(!p)) 3086 if (unlikely(!p))
3087 goto out_overflow; 3087 goto out_overflow;
3088 *attrlen = be32_to_cpup(p); 3088 *attrlen = be32_to_cpup(p);
3089 *savep = xdr->p; 3089 *savep = xdr_stream_pos(xdr);
3090 return 0; 3090 return 0;
3091out_overflow: 3091out_overflow:
3092 print_overflow_msg(__func__, xdr); 3092 print_overflow_msg(__func__, xdr);
@@ -4068,10 +4068,10 @@ static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, str
4068 return status; 4068 return status;
4069} 4069}
4070 4070
4071static int verify_attr_len(struct xdr_stream *xdr, __be32 *savep, uint32_t attrlen) 4071static int verify_attr_len(struct xdr_stream *xdr, unsigned int savep, uint32_t attrlen)
4072{ 4072{
4073 unsigned int attrwords = XDR_QUADLEN(attrlen); 4073 unsigned int attrwords = XDR_QUADLEN(attrlen);
4074 unsigned int nwords = xdr->p - savep; 4074 unsigned int nwords = (xdr_stream_pos(xdr) - savep) >> 2;
4075 4075
4076 if (unlikely(attrwords != nwords)) { 4076 if (unlikely(attrwords != nwords)) {
4077 dprintk("%s: server returned incorrect attribute length: " 4077 dprintk("%s: server returned incorrect attribute length: "
@@ -4193,7 +4193,7 @@ out_overflow:
4193 4193
4194static int decode_server_caps(struct xdr_stream *xdr, struct nfs4_server_caps_res *res) 4194static int decode_server_caps(struct xdr_stream *xdr, struct nfs4_server_caps_res *res)
4195{ 4195{
4196 __be32 *savep; 4196 unsigned int savep;
4197 uint32_t attrlen, bitmap[3] = {0}; 4197 uint32_t attrlen, bitmap[3] = {0};
4198 int status; 4198 int status;
4199 4199
@@ -4222,7 +4222,7 @@ xdr_error:
4222 4222
4223static int decode_statfs(struct xdr_stream *xdr, struct nfs_fsstat *fsstat) 4223static int decode_statfs(struct xdr_stream *xdr, struct nfs_fsstat *fsstat)
4224{ 4224{
4225 __be32 *savep; 4225 unsigned int savep;
4226 uint32_t attrlen, bitmap[3] = {0}; 4226 uint32_t attrlen, bitmap[3] = {0};
4227 int status; 4227 int status;
4228 4228
@@ -4254,7 +4254,7 @@ xdr_error:
4254 4254
4255static int decode_pathconf(struct xdr_stream *xdr, struct nfs_pathconf *pathconf) 4255static int decode_pathconf(struct xdr_stream *xdr, struct nfs_pathconf *pathconf)
4256{ 4256{
4257 __be32 *savep; 4257 unsigned int savep;
4258 uint32_t attrlen, bitmap[3] = {0}; 4258 uint32_t attrlen, bitmap[3] = {0};
4259 int status; 4259 int status;
4260 4260
@@ -4299,7 +4299,8 @@ out_overflow:
4299static int decode_first_threshold_item4(struct xdr_stream *xdr, 4299static int decode_first_threshold_item4(struct xdr_stream *xdr,
4300 struct nfs4_threshold *res) 4300 struct nfs4_threshold *res)
4301{ 4301{
4302 __be32 *p, *savep; 4302 __be32 *p;
4303 unsigned int savep;
4303 uint32_t bitmap[3] = {0,}, attrlen; 4304 uint32_t bitmap[3] = {0,}, attrlen;
4304 int status; 4305 int status;
4305 4306
@@ -4503,7 +4504,7 @@ static int decode_getfattr_generic(struct xdr_stream *xdr, struct nfs_fattr *fat
4503 struct nfs_fh *fh, struct nfs4_fs_locations *fs_loc, 4504 struct nfs_fh *fh, struct nfs4_fs_locations *fs_loc,
4504 const struct nfs_server *server) 4505 const struct nfs_server *server)
4505{ 4506{
4506 __be32 *savep; 4507 unsigned int savep;
4507 uint32_t attrlen, 4508 uint32_t attrlen,
4508 bitmap[3] = {0}; 4509 bitmap[3] = {0};
4509 int status; 4510 int status;
@@ -4615,7 +4616,7 @@ static int decode_attr_layout_blksize(struct xdr_stream *xdr, uint32_t *bitmap,
4615 4616
4616static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo) 4617static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo)
4617{ 4618{
4618 __be32 *savep; 4619 unsigned int savep;
4619 uint32_t attrlen, bitmap[3]; 4620 uint32_t attrlen, bitmap[3];
4620 int status; 4621 int status;
4621 4622
@@ -5044,7 +5045,8 @@ decode_restorefh(struct xdr_stream *xdr)
5044static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req, 5045static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req,
5045 struct nfs_getaclres *res) 5046 struct nfs_getaclres *res)
5046{ 5047{
5047 __be32 *savep, *bm_p; 5048 unsigned int savep;
5049 __be32 *bm_p;
5048 uint32_t attrlen, 5050 uint32_t attrlen,
5049 bitmap[3] = {0}; 5051 bitmap[3] = {0};
5050 int status; 5052 int status;
@@ -7076,6 +7078,7 @@ out:
7076int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, 7078int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry,
7077 int plus) 7079 int plus)
7078{ 7080{
7081 unsigned int savep;
7079 uint32_t bitmap[3] = {0}; 7082 uint32_t bitmap[3] = {0};
7080 uint32_t len; 7083 uint32_t len;
7081 __be32 *p = xdr_inline_decode(xdr, 4); 7084 __be32 *p = xdr_inline_decode(xdr, 4);
@@ -7114,7 +7117,7 @@ int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry,
7114 if (decode_attr_bitmap(xdr, bitmap) < 0) 7117 if (decode_attr_bitmap(xdr, bitmap) < 0)
7115 goto out_overflow; 7118 goto out_overflow;
7116 7119
7117 if (decode_attr_length(xdr, &len, &p) < 0) 7120 if (decode_attr_length(xdr, &len, &savep) < 0)
7118 goto out_overflow; 7121 goto out_overflow;
7119 7122
7120 if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh, 7123 if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh,