Fix a possible out of bound access which may happen when handling
indirect descs in split ring.
Fixes:
1be4ebb1c464 ("vhost: support indirect descriptor in mergeable Rx")
Cc: stable@dpdk.org
Reported-by: Haiyue Wang <haiyue.wang@intel.com>
Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
uint32_t len = 0;
uint64_t dlen;
uint32_t nr_descs = vq->size;
+ uint32_t cnt = 0;
struct vring_desc *descs = vq->desc;
struct vring_desc *idesc = NULL;
}
while (1) {
- if (unlikely(idx >= vq->size)) {
- free_ind_table(idesc);
- return -1;
- }
-
- if (unlikely(nr_descs-- == 0)) {
+ if (unlikely(idx >= nr_descs || cnt++ >= nr_descs)) {
free_ind_table(idesc);
return -1;
}