aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4xdr.c
diff options
context:
space:
mode:
authorBryan Schumaker <bjschuma@netapp.com>2011-04-13 14:31:31 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2011-04-13 15:12:23 -0400
commitc3dfc2808ab82b13f8b6db62189da959c2eadeea (patch)
tree5eb6f11f712396e67544539a4a28d4503d54a6b9 /fs/nfs/nfs4xdr.c
parent9b7160c55a41dd2fec3d467f979e55782d3f92ad (diff)
NFS: Use correct variable for page bounds checking
While decoding a secinfo reply, I store the list of supported sec flavors on a page accessible through res->flavors. Before reading each new flavor, I do some math to determine if there is enough space left on this page, and I break out of my read look if there isn't. In order to perform this check correctly, I need to use the address of res->flavors, rather than the address of res. When this loop was broken early I lied to the caller and told them that the entire list had been decoded. This could lead to problems if the caller tries to use any the garbage data claiming to be a valid sec flavor. I fixed this by using res->flavors->num_flavors as a counter, incrementing it every time a sec flavor is successfully decoded. Signed-off-by: Bryan Schumaker <bjschuma@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs4xdr.c')
-rw-r--r--fs/nfs/nfs4xdr.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index dddfb5795d7b..ba952bdc4d62 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -4838,17 +4838,19 @@ static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res)
4838 struct nfs4_secinfo_flavor *sec_flavor; 4838 struct nfs4_secinfo_flavor *sec_flavor;
4839 int status; 4839 int status;
4840 __be32 *p; 4840 __be32 *p;
4841 int i; 4841 int i, num_flavors;
4842 4842
4843 status = decode_op_hdr(xdr, OP_SECINFO); 4843 status = decode_op_hdr(xdr, OP_SECINFO);
4844 p = xdr_inline_decode(xdr, 4); 4844 p = xdr_inline_decode(xdr, 4);
4845 if (unlikely(!p)) 4845 if (unlikely(!p))
4846 goto out_overflow; 4846 goto out_overflow;
4847 res->flavors->num_flavors = be32_to_cpup(p);
4848 4847
4849 for (i = 0; i < res->flavors->num_flavors; i++) { 4848 res->flavors->num_flavors = 0;
4849 num_flavors = be32_to_cpup(p);
4850
4851 for (i = 0; i < num_flavors; i++) {
4850 sec_flavor = &res->flavors->flavors[i]; 4852 sec_flavor = &res->flavors->flavors[i];
4851 if ((char *)&sec_flavor[1] - (char *)res > PAGE_SIZE) 4853 if ((char *)&sec_flavor[1] - (char *)res->flavors > PAGE_SIZE)
4852 break; 4854 break;
4853 4855
4854 p = xdr_inline_decode(xdr, 4); 4856 p = xdr_inline_decode(xdr, 4);
@@ -4860,6 +4862,7 @@ static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res)
4860 if (decode_secinfo_gss(xdr, sec_flavor)) 4862 if (decode_secinfo_gss(xdr, sec_flavor))
4861 break; 4863 break;
4862 } 4864 }
4865 res->flavors->num_flavors++;
4863 } 4866 }
4864 4867
4865 return 0; 4868 return 0;