From: Maxime Coquelin Subject: Re: [PATCH 1/3] vhost: fix dead loop in enqueue path Date: Mon, 23 Jan 2017 08:56:04 +0100 Message-ID: <99093bd1-0970-b374-5261-7e91d33fe4b6@redhat.com> References: <1485074820-8956-1-git-send-email-yuanhan.liu@linux.intel.com> <1485074820-8956-2-git-send-email-yuanhan.liu@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Cc: stable@dpdk.org To: Yuanhan Liu , dev@dpdk.org Return-path: In-Reply-To: <1485074820-8956-2-git-send-email-yuanhan.liu@linux.intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 01/22/2017 09:46 AM, Yuanhan Liu wrote: > If a malicious guest forges a dead loop desc chain (let desc->next point > to itself) and desc->len is zero, this could lead to a dead loop in > copy_mbuf_to_desc(following is a simplified code to show this issue > clearly): > > while (mbuf_is_not_totally_consumed) { > if (desc_avail == 0) { > desc = &descs[desc->next]; > desc_avail = desc->len; > } > > COPY(desc, mbuf, desc_avail); > } > > I have actually fixed a same issue before: a436f53ebfeb ("vhost: avoid > dead loop chain"); it fixes the dequeue path though, leaving the enqueue > path still vulnerable. > > The fix is the same. Add a var nr_desc to avoid the dead loop. > > Fixes: f1a519ad981c ("vhost: fix enqueue/dequeue to handle chained vring descriptors") > > Cc: stable@dpdk.org > Reported-by: Xieming Katty > Signed-off-by: Yuanhan Liu > --- > lib/librte_vhost/virtio_net.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) Thanks for the fix: Reviewed-by: Maxime Coquelin - Maxime