Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3775380imu; Mon, 7 Jan 2019 09:12:33 -0800 (PST) X-Google-Smtp-Source: ALg8bN7210nKdVf1a8F+xeaDvpUhWRLg07EmjxYDnvnWDTEvky8JbYqeichO3OvnWKHM7DhMDWn5 X-Received: by 2002:a63:9d05:: with SMTP id i5mr10757839pgd.98.1546881153114; Mon, 07 Jan 2019 09:12:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546881153; cv=none; d=google.com; s=arc-20160816; b=OLgfSgGHE81/xwoq2e/gMnOgez5+BGvZF0GZHx4JNNxA0HxR2/uzzRFMJ58A+xYjHk RA0Y2QduiHJLEVaoCP1q51UR4XLr1c2wpQ8u5dgTh0k91A23ZKyO+GXArF/tulSKN2US dp3V0sopdBmRB43Ox8DkzLVpnWfBGGqjX3QDgkWF6ilsbd76xgQCWg4/bDSn4bC9gTfx zU4o8RQNKlzU1TzxAiHjvD6xh0gIgjF9ZfdRe8W+p9mHrnP9gC5cO0hjiFNaiUmwrzJb B9AvLq2Dzbj3jcfPlCD1DVmsqT8gHhaW9/UdwP5L6/ufW0FEjOXTSPbJOz1uDAAsRynz R3jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cngesjO+JcOIOLydnYCYqjcXRq1MzarbsaVbqV+gD4Y=; b=VlzKJ+OkbfAeUiw/k2blX2ipdM6rSKFW8XA0I2rsl861J0aMUWPezsx35pBDMTQ2VT 1ewEtE7rYk1QWeLAIS9hkgyi0Vd9wHbT1GJIjQF2qmJYziWiuZv/Kek7+QnK3RVaY9on lFsLQ37fLrq+gA8tgH4As7XLjPVOETAlFY8fcDylW/6cNqUCBa5iJL4nexSTXrthmLdL N9wLmTH1weU9WhlfpOh95ToAb0M6TgKOEya0esWUqnsXHtlxXdcpHM0svQ7zYkvEGqY2 adM7hqU3f6KPklYo8jO9w2xoLDlSRUxoI6JLgQaOGYqXXmBeG1ZMFZKH3k5f+v7DnF8e yAvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LclNjGbq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w10si13388830pgj.214.2019.01.07.09.12.17; Mon, 07 Jan 2019 09:12:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LclNjGbq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730222AbfAGNAj (ORCPT + 99 others); Mon, 7 Jan 2019 08:00:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:48118 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729347AbfAGNAh (ORCPT ); Mon, 7 Jan 2019 08:00:37 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 326812089F; Mon, 7 Jan 2019 13:00:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546866036; bh=udXtmA4bJseErsWw12JZH8ruzcOzkCs5pfO07hz+xLE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LclNjGbqD09KnMEX5hVmWju/dimkEABS0RegPnEKHpvm/EaTe+aWHj0Eal/T/EE1/ cVEBkFJebK5F5wACpKxXc5bCSj4Gq4QCLDjRFz3c51i89/tUHeJiiKpnAsw/lhcCFZ zhqfnpqu0M3kpHSgQBuDuwWqiX+Lixqm0jwwD9Zs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , "David S. Miller" Subject: [PATCH 4.14 024/101] vhost: make sure used idx is seen before log in vhost_add_used_n() Date: Mon, 7 Jan 2019 13:32:12 +0100 Message-Id: <20190107105334.255094640@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190107105330.372621917@linuxfoundation.org> References: <20190107105330.372621917@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jason Wang [ Upstream commit 841df922417eb82c835e93d4b93eb6a68c99d599 ] We miss a write barrier that guarantees used idx is updated and seen before log. This will let userspace sync and copy used ring before used idx is update. Fix this by adding a barrier before log_write(). Fixes: 8dd014adfea6f ("vhost-net: mergeable buffers support") Acked-by: Michael S. Tsirkin Signed-off-by: Jason Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/vhost/vhost.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -2231,6 +2231,8 @@ int vhost_add_used_n(struct vhost_virtqu return -EFAULT; } if (unlikely(vq->log_used)) { + /* Make sure used idx is seen before log. */ + smp_wmb(); /* Log used index update. */ log_write(vq->log_base, vq->log_addr + offsetof(struct vring_used, idx),