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=-5.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_MUTT 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 88E65C43381 for ; Thu, 21 Feb 2019 11:52:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 58F8220880 for ; Thu, 21 Feb 2019 11:52:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kroah.com header.i=@kroah.com header.b="gT3R5GBl"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="M14VgknT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727866AbfBULwZ (ORCPT ); Thu, 21 Feb 2019 06:52:25 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:48707 "EHLO wout2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727740AbfBULut (ORCPT ); Thu, 21 Feb 2019 06:50:49 -0500 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 606502DEE; Thu, 21 Feb 2019 06:50:48 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 21 Feb 2019 06:50:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kroah.com; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=S+9I4FgpoxS0Vqon41EG9OfcaHQ emyQXjxWjBwRCRNg=; b=gT3R5GBlB59qIhN4OexmkrcqWJowFpISiP3Z94ohePH GxJA3KzVQVG283/v3eWsZyLQQwOdxSYKdmr/IlJVdV3omlofbi7Z7f/iQAHSKduN jff74CqKAIGb6AYNEx+qeKFgzZXRfnA2v0iPNk1GFaXIrgYJMyoiNeXmqJz8Qk1b pr7NSqOonmFm7Q6ecv+hhfS/EqQ/lkls5slY956dM6/fHwNVMwvi6eMb4+gEnQXs V+BLHXtO9dmQKmmHnQ7mp37QsNeIYBF2GyLK++SiDkPsdAJZRCiS6P5d5K+D/nra UroS+6u8WIukbBGQJl6CFrLk36ZZaaDBi+iOfTyxwog== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=S+9I4F gpoxS0Vqon41EG9OfcaHQemyQXjxWjBwRCRNg=; b=M14VgknT6P6kkOYFp5Tq/j tRuT36Ydt9z8tyXnApVTQkYv/0ALzWUuuFBWmQXzEE5FDOTp56XukrtC4ckippPR Li/poSBe730piS+J2NllYfGAPtJYxCwmfbgyujzefb5PFaZYUaAEbES4M3GUAd3O uZNM70pp0DPYvoRs8EDQ+cDpU54J73Rq+lp4aZQ4MkYxe+ypbT6d5O0OYn0QFE8J a47zvQ7oZN9sTSY5UYP7Bho7R1ambnhAQv9dGSZ3NaCPlCqfi0BCFyAIOME3dH9C qBw+Au9A5iKQ45g1pYq0pttEg3U9xs8y45a2lXP0/nQ7PFsG2sshsxOgiaq0NfLg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddrtdekgdefheculddtuddrgedtledrtddtmd cutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjfgesthdtredttdervdenucfhrhhomhepifhrvghg ucfmjfcuoehgrhgvgheskhhrohgrhhdrtghomheqnecukfhppeekfedrkeeirdekledrud dtjeenucfrrghrrghmpehmrghilhhfrhhomhepghhrvghgsehkrhhorghhrdgtohhmnecu vehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from localhost (5356596b.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) by mail.messagingengine.com (Postfix) with ESMTPA id 15BA8E419A; Thu, 21 Feb 2019 06:50:46 -0500 (EST) Date: Thu, 21 Feb 2019 12:50:45 +0100 From: Greg KH To: Jann Horn Cc: stable@vger.kernel.org, Paolo Bonzini Subject: Re: [PATCH 3.18,4.4] kvm: fix kvm_ioctl_create_device() reference counting (CVE-2019-6974) Message-ID: <20190221115045.GA25198@kroah.com> References: <20190218165328.100978-1-jannh@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190218165328.100978-1-jannh@google.com> User-Agent: Mutt/1.11.3 (2019-02-01) Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Mon, Feb 18, 2019 at 05:53:28PM +0100, Jann Horn wrote: > commit cfa39381173d5f969daf43582c95ad679189cbc9 upstream. > > kvm_ioctl_create_device() does the following: > > 1. creates a device that holds a reference to the VM object (with a borrowed > reference, the VM's refcount has not been bumped yet) > 2. initializes the device > 3. transfers the reference to the device to the caller's file descriptor table > 4. calls kvm_get_kvm() to turn the borrowed reference to the VM into a real > reference > > The ownership transfer in step 3 must not happen before the reference to the VM > becomes a proper, non-borrowed reference, which only happens in step 4. > After step 3, an attacker can close the file descriptor and drop the borrowed > reference, which can cause the refcount of the kvm object to drop to zero. > > This means that we need to grab a reference for the device before > anon_inode_getfd(), otherwise the VM can disappear from under us. > > Fixes: 852b6d57dc7f ("kvm: add device control API") > Cc: stable@kernel.org > Signed-off-by: Jann Horn > --- > virt/kvm/kvm_main.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) Now queued up, thanks. greg k-h