Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp172077imd; Wed, 31 Oct 2018 16:46:14 -0700 (PDT) X-Google-Smtp-Source: AJdET5cJwUhGobP50+sjdHPJoYjeYhIZemlJoW8cdFOc6TC0Q4Btkx4ewxVC+czaANCAnnFxou1P X-Received: by 2002:a62:1803:: with SMTP id 3-v6mr5378059pfy.21.1541029574293; Wed, 31 Oct 2018 16:46:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541029574; cv=none; d=google.com; s=arc-20160816; b=O8EqJPkgUdtSyoUMoWsP/BmdGyNib2bH4bYKBK+rCuq817Hn3+Tua1h+uZQvnPtIFf oc9VpSUSDoYngKlz3d4B/BSXR1YgBknNU7rHAeSTSKBYV4xv3XUd029jqO1isHoSNHNH JUD4UcTxmSFGtDoLZsKtsMpZleb5kTk/BRwokwXpHg2a43bT8bW7MZiPAk4caC7zKdwS lvUmh1bAQ1luJToWHpn7nOAV6OBfqQFZxRavI/0ue6zQ/+wB25wvJCZmOfoCJUhTgY1B RdoAQEfAGLw5LXrtojuQFjrtCkH3+jA03dtsRU5dHoQEweo9qjkIIfr3/FJ07QFSvdaR sc4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=rsCj8204/gNTPdu5paeC+kteZN3pCS5RNg6b1EE5KTQ=; b=GtmTIaqMEGycw9R8j0KoCcZcwyhBkCphBP9BeMZj3g273pFuTuWRqNb91NB6GGhq8d yGH40C9mzknq8GkzXM2DpeVIJx4doPbnxarGEtHcuHJdb19EvIb64O1SbbnH1kAjReGL OO/pwGunotYf6cIMsasb+kP8f0P76oCzOOWn9hAv51lYVz2YWUmZ45BU+UZT9Fah9aOA IfANQ9fhPgEJUd2ulWJytIsurs1grvoUa5EnhVAp9cdMjuMOcFmo+StFAokwH+dn+BYg /m45HrQmM8f1DdW2j+j+PeolhqM/XQNhek9QSTGr33TOzvEjhOID4Kjq5kvPfe4AdgHf ZMPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bzbiKVrL; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 23-v6si19943665pfu.2.2018.10.31.16.45.59; Wed, 31 Oct 2018 16:46:14 -0700 (PDT) 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=bzbiKVrL; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728973AbeKAIHe (ORCPT + 99 others); Thu, 1 Nov 2018 04:07:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:55398 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728910AbeKAIHc (ORCPT ); Thu, 1 Nov 2018 04:07:32 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5FBF32081B; Wed, 31 Oct 2018 23:07:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027242; bh=TcLOVOdKOaH99qbyMhI0msVsik6TBT9a+p7G2sAB1LI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bzbiKVrLEZGxmxcySvxAOVEOvLWWqBdwl0Fhzk2gEATUusCDdhvo+Pq0Y7WvykmD6 n0+KYWnEBZAwyJYglhmazae3oyLK+dppNNadq9wfzd28rPeIXuuKR1QJxy5gBxWXln 4YdqqE274+DAxg7bBUhUx3IbYcdmp7oZ8isjKjYY= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jorgen Hansen , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH AUTOSEL 4.19 110/146] VMCI: Resource wildcard match fixed Date: Wed, 31 Oct 2018 19:05:05 -0400 Message-Id: <20181031230541.28822-110-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jorgen Hansen [ Upstream commit 11924ba5e671d6caef1516923e2bd8c72929a3fe ] When adding a VMCI resource, the check for an existing entry would ignore that the new entry could be a wildcard. This could result in multiple resource entries that would match a given handle. One disastrous outcome of this is that the refcounting used to ensure that delayed callbacks for VMCI datagrams have run before the datagram is destroyed can be wrong, since the refcount could be increased on the duplicate entry. This in turn leads to a use after free bug. This issue was discovered by Hangbin Liu using KASAN and syzkaller. Fixes: bc63dedb7d46 ("VMCI: resource object implementation") Reported-by: Hangbin Liu Reviewed-by: Adit Ranadive Reviewed-by: Vishnu Dasa Signed-off-by: Jorgen Hansen Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/misc/vmw_vmci/vmci_driver.c | 2 +- drivers/misc/vmw_vmci/vmci_resource.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/misc/vmw_vmci/vmci_driver.c b/drivers/misc/vmw_vmci/vmci_driver.c index d7eaf1eb11e7..003bfba40758 100644 --- a/drivers/misc/vmw_vmci/vmci_driver.c +++ b/drivers/misc/vmw_vmci/vmci_driver.c @@ -113,5 +113,5 @@ module_exit(vmci_drv_exit); MODULE_AUTHOR("VMware, Inc."); MODULE_DESCRIPTION("VMware Virtual Machine Communication Interface."); -MODULE_VERSION("1.1.5.0-k"); +MODULE_VERSION("1.1.6.0-k"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/misc/vmw_vmci/vmci_resource.c b/drivers/misc/vmw_vmci/vmci_resource.c index 1ab6e8737a5f..da1ee2e1ba99 100644 --- a/drivers/misc/vmw_vmci/vmci_resource.c +++ b/drivers/misc/vmw_vmci/vmci_resource.c @@ -57,7 +57,8 @@ static struct vmci_resource *vmci_resource_lookup(struct vmci_handle handle, if (r->type == type && rid == handle.resource && - (cid == handle.context || cid == VMCI_INVALID_ID)) { + (cid == handle.context || cid == VMCI_INVALID_ID || + handle.context == VMCI_INVALID_ID)) { resource = r; break; } -- 2.17.1