From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0247C4CEC5 for ; Fri, 13 Sep 2019 13:21:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A25C820717 for ; Fri, 13 Sep 2019 13:21:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568380917; bh=2pVP602cg00sCTVTT665bmE2gN0S7xfI1q9R3UMw/Go=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=xWWQTzBP9rvCwDA3EOqoyh6EHlFAtRs+53g4cNkvndqlPhs9xdcjakNxDd2iLdDYf X3PCHb5gl0xFNQJWW04M0RI5fGCjwM6O92omPd8crToNVOWYjL/QQ7Y3HuFLVGGEAX /SBwDGtTtL2RgfuUhpTagRz0qPVCOzpVV3XSQkVA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390938AbfIMNV4 (ORCPT ); Fri, 13 Sep 2019 09:21:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:51844 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390926AbfIMNVy (ORCPT ); Fri, 13 Sep 2019 09:21:54 -0400 Received: from localhost (unknown [104.132.45.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5E4C4206BB; Fri, 13 Sep 2019 13:21:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568380913; bh=2pVP602cg00sCTVTT665bmE2gN0S7xfI1q9R3UMw/Go=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vYkd9s5dAYrycD3TNDbllrMEMBUF7rn97WTEXVXKXTyhJrAkOvxzqZokYPcisBFY0 mWlSdI4nwE9B+A/gLEqL1sAF3xyDPV7Vekz03R3WEZMEAvq+pxcgHTY9Vo8RVcfYAD Ign6uJZOjwW66KkzOgb/EH2G/KToRNoQQF3fa4ak= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang Subject: [PATCH 5.2 36/37] vhost: block speculation of translated descriptors Date: Fri, 13 Sep 2019 14:07:41 +0100 Message-Id: <20190913130522.155505270@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190913130510.727515099@linuxfoundation.org> References: <20190913130510.727515099@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michael S. Tsirkin commit a89db445fbd7f1f8457b03759aa7343fa530ef6b upstream. iovec addresses coming from vhost are assumed to be pre-validated, but in fact can be speculated to a value out of range. Userspace address are later validated with array_index_nospec so we can be sure kernel info does not leak through these addresses, but vhost must also not leak userspace info outside the allowed memory table to guests. Following the defence in depth principle, make sure the address is not validated out of node range. Signed-off-by: Michael S. Tsirkin Cc: stable@vger.kernel.org Acked-by: Jason Wang Tested-by: Jason Wang Signed-off-by: Greg Kroah-Hartman --- drivers/vhost/vhost.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -1965,8 +1965,10 @@ static int translate_desc(struct vhost_v _iov = iov + ret; size = node->size - addr + node->start; _iov->iov_len = min((u64)len - s, size); - _iov->iov_base = (void __user *)(unsigned long) - (node->userspace_addr + addr - node->start); + _iov->iov_base = (void __user *) + ((unsigned long)node->userspace_addr + + array_index_nospec((unsigned long)(addr - node->start), + node->size)); s += size; addr += size; ++ret;