nfs/blocklayout: Check max uuids and devices before decoding
Avoid nfs return uuids/devices larger than maximum. Signed-off-by: Kinglong Mee <kinglongmee@gmail.com> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
This commit is contained in:

committed by
Trond Myklebust

parent
ecc2b88c4a
commit
c77efc1e78
@@ -65,8 +65,8 @@ nfs4_block_decode_volume(struct xdr_stream *xdr, struct pnfs_block_volume *b)
|
|||||||
if (!p)
|
if (!p)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
b->simple.nr_sigs = be32_to_cpup(p++);
|
b->simple.nr_sigs = be32_to_cpup(p++);
|
||||||
if (!b->simple.nr_sigs) {
|
if (!b->simple.nr_sigs || b->simple.nr_sigs > PNFS_BLOCK_MAX_UUIDS) {
|
||||||
dprintk("no signature\n");
|
dprintk("Bad signature count: %d\n", b->simple.nr_sigs);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,7 +105,12 @@ nfs4_block_decode_volume(struct xdr_stream *xdr, struct pnfs_block_volume *b)
|
|||||||
p = xdr_inline_decode(xdr, 4);
|
p = xdr_inline_decode(xdr, 4);
|
||||||
if (!p)
|
if (!p)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
b->concat.volumes_count = be32_to_cpup(p++);
|
b->concat.volumes_count = be32_to_cpup(p++);
|
||||||
|
if (b->concat.volumes_count > PNFS_BLOCK_MAX_DEVICES) {
|
||||||
|
dprintk("Too many volumes: %d\n", b->concat.volumes_count);
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
p = xdr_inline_decode(xdr, b->concat.volumes_count * 4);
|
p = xdr_inline_decode(xdr, b->concat.volumes_count * 4);
|
||||||
if (!p)
|
if (!p)
|
||||||
@@ -117,8 +122,13 @@ nfs4_block_decode_volume(struct xdr_stream *xdr, struct pnfs_block_volume *b)
|
|||||||
p = xdr_inline_decode(xdr, 8 + 4);
|
p = xdr_inline_decode(xdr, 8 + 4);
|
||||||
if (!p)
|
if (!p)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
p = xdr_decode_hyper(p, &b->stripe.chunk_size);
|
p = xdr_decode_hyper(p, &b->stripe.chunk_size);
|
||||||
b->stripe.volumes_count = be32_to_cpup(p++);
|
b->stripe.volumes_count = be32_to_cpup(p++);
|
||||||
|
if (b->stripe.volumes_count > PNFS_BLOCK_MAX_DEVICES) {
|
||||||
|
dprintk("Too many volumes: %d\n", b->stripe.volumes_count);
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
p = xdr_inline_decode(xdr, b->stripe.volumes_count * 4);
|
p = xdr_inline_decode(xdr, b->stripe.volumes_count * 4);
|
||||||
if (!p)
|
if (!p)
|
||||||
|
Reference in New Issue
Block a user