On Wed, Dec 12, 2018 at 05:17:21PM +0530, P J P wrote: > From: Prasad J Pandit <p...@fedoraproject.org> > > rdma back-end has scatter/gather array ibv_sge[MAX_SGE=4] set > to have 4 elements. A guest could send a 'PvrdmaSqWqe' ring element > with 'num_sge' set to > MAX_SGE, which may lead to OOB access issue. > Add check to avoid it. > > Reported-by: Saar Amar <saaram...@gmail.com> > Signed-off-by: Prasad J Pandit <p...@fedoraproject.org> > --- > hw/rdma/rdma_backend.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > Update v1: use new error code VENDOR_ERR_INV_NUM_SGE > -> https://lists.gnu.org/archive/html/qemu-devel/2018-12/msg02220.html > > diff --git a/hw/rdma/rdma_backend.c b/hw/rdma/rdma_backend.c > index ae1e4dcb29..bd4710d16f 100644 > --- a/hw/rdma/rdma_backend.c > +++ b/hw/rdma/rdma_backend.c > @@ -476,9 +476,9 @@ void rdma_backend_post_send(RdmaBackendDev *backend_dev, > } > > pr_dbg("num_sge=%d\n", num_sge); > - if (!num_sge) { > - pr_dbg("num_sge=0\n"); > - complete_work(IBV_WC_GENERAL_ERR, VENDOR_ERR_NO_SGE, ctx); > + if (!num_sge || num_sge > MAX_SGE) { > + pr_dbg("invalid num_sge=%d\n", num_sge); > + complete_work(IBV_WC_GENERAL_ERR, VENDOR_ERR_INV_NUM_SGE, ctx); > return; > } > > @@ -603,9 +603,9 @@ void rdma_backend_post_recv(RdmaBackendDev *backend_dev, > } > > pr_dbg("num_sge=%d\n", num_sge); > - if (!num_sge) { > - pr_dbg("num_sge=0\n"); > - complete_work(IBV_WC_GENERAL_ERR, VENDOR_ERR_NO_SGE, ctx); > + if (!num_sge || num_sge > MAX_SGE) { > + pr_dbg("invalid num_sge=%d\n", num_sge); > + complete_work(IBV_WC_GENERAL_ERR, VENDOR_ERR_INV_NUM_SGE, ctx); > return; > }
Reviewed-by: Yuval Shaia <yuval.sh...@oracle.com> > > -- > 2.19.2 >