Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756143AbcCBAp5 (ORCPT ); Tue, 1 Mar 2016 19:45:57 -0500 Received: from mail333.us4.mandrillapp.com ([205.201.137.77]:43800 "EHLO mail333.us4.mandrillapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755949AbcCAX4s (ORCPT ); Tue, 1 Mar 2016 18:56:48 -0500 DomainKey-Signature: a=rsa-sha1; c=nofws; q=dns; s=mandrill; d=linuxfoundation.org; b=KFXNeNw84ClcK8Qkh8v/8cqeqz2SxdVUrgr14Vc/cTFHtziiOLv4KIZelL6FxcKCjXSduBNCqmEw mqkPRet0mIPxhzwgfHgWUQw+LFKrjHCHzFgz2b9PoMwSiV1dGlPGoQQ0r7bw5cRNj4/Ap9S5WNoC JTv6badKyR/iyWFgC+A=; From: Greg Kroah-Hartman Subject: [PATCH 4.4 166/342] virtio_balloon: fix race by fill and leak X-Mailer: git-send-email 2.7.2 To: Cc: Greg Kroah-Hartman , , Minchan Kim , "Michael S. Tsirkin" Message-Id: <20160301234533.324490742@linuxfoundation.org> In-Reply-To: <20160301234527.990448862@linuxfoundation.org> References: <20160301234527.990448862@linuxfoundation.org> X-Report-Abuse: Please forward a copy of this message, including all headers, to abuse@mandrill.com X-Report-Abuse: You can also report abuse here: http://mandrillapp.com/contact/abuse?id=30481620.d9778125a16f4c3882021ef558068dd5 X-Mandrill-User: md_30481620 Date: Tue, 01 Mar 2016 23:54:39 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1206 Lines: 40 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Minchan Kim commit f68b992bbb474641881932c61c92dcfa6f5b3689 upstream. During my compaction-related stuff, I encountered a bug with ballooning. With repeated inflating and deflating cycle, guest memory( ie, cat /proc/meminfo | grep MemTotal) is decreased and couldn't be recovered. The reason is balloon_lock doesn't cover release_pages_balloon so struct virtio_balloon fields could be overwritten by race of fill_balloon(e,g, vb->*pfns could be critical). This patch fixes it in my test. Signed-off-by: Minchan Kim Signed-off-by: Michael S. Tsirkin Signed-off-by: Greg Kroah-Hartman --- drivers/virtio/virtio_balloon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -209,8 +209,8 @@ static unsigned leak_balloon(struct virt */ if (vb->num_pfns != 0) tell_host(vb, vb->deflate_vq); - mutex_unlock(&vb->balloon_lock); release_pages_balloon(vb); + mutex_unlock(&vb->balloon_lock); return num_freed_pages; }