Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3532570pxb; Mon, 1 Mar 2021 12:30:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJxaLrMWayfYRPT9FdVYOGQ6Cm9hjEeaeasRYRmjdCC5Fv4NlWVljNAMhVluARXrDFfyt9Vv X-Received: by 2002:aa7:cf14:: with SMTP id a20mr3729781edy.49.1614630637696; Mon, 01 Mar 2021 12:30:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614630637; cv=none; d=google.com; s=arc-20160816; b=EQ0SaisbJDDYMJ8FuHX4tIMvnV3O03m1KZwkzKXZ4ic2pE042mEsrOLTApZD/8PKY/ f1ZrXEO/+3P3y5G3sWLLMjv5dCJSAI1JX85Sdyz3lpf3xAKMdDCfUgcGy7Xr3ilb711H j8vVGiGLeaEWQixj5LtXyNpjlznxDG35fLAqfW2ve80FrYGIkm+QdzakkIXh7GE5ISoh 18Cjo89BuByAfps+OUmQq6Q+SKArNGpNKEIGl+sb/qPl1sYwihVffnxrsdUFBUmsoOFR wq+LwEiDQ3MMqonEtYT5VRcjaaPZHX5oA6c0T0AfbtJt+c3VTvUgl6QDzJF5c/5i2+SX DEqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=o3Neuj/CjSQi3FU+mceG8pgRKszJVRC5YnqqWhsRVHo=; b=XGscUVoZcoNCI/fpZus9k1mb0xNMEqFcrVVqNbVApGuiCZ78Qyj9RW+YLSItAHJDHP VFV0wifHTdUATPmJpWi0bs7ujKMOtoPyOLjNQJzJDrkKnIneuVZY44HFtU4/XfTG/wNs eLy2WhBDRwg1cetbwLVh/dqReIim0AEidYwKlk7FLH6mEGuuJDYK/jcB1H4z91/fQziZ V150NqjeWZpLiRxWm5IiUKo4Kgv7RZzU0xW1Rb8LtnQpRBgtCQIIkUJmKTASBJH7SdjF +ReYF7ghVBEF6xaE80I1ZLqB015CvmZ61FTluMl+Tqy50Z8Hn4cDRH1iODW29TZG/RW7 w9Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=blAJ3U9w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b26si3347707eja.162.2021.03.01.12.30.14; Mon, 01 Mar 2021 12:30:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=blAJ3U9w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242141AbhCAU11 (ORCPT + 99 others); Mon, 1 Mar 2021 15:27:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:37624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235426AbhCARGg (ORCPT ); Mon, 1 Mar 2021 12:06:36 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7F18464FFD; Mon, 1 Mar 2021 16:39:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614616796; bh=5zAsZjeZUebQrZX0uTD1JXEsi/njt/SO9N1rnxhTnAI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=blAJ3U9ws/nYBb8KpZ3dbTNnBu8ZO5WztmRnOzBcQ95Jh0Zgg/cUOXBXO5vnRZrPh isnCmp7UUbFskuQB0NIJe6eFaDX2aRrEIZCV2fLTT4afIyxyhlkay5y4gitMPJLblx IY7TyrmCK73CUP0OwUEl32frh/F9IyjpYgcClKBw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Juan Vazquez , "Andrea Parri (Microsoft)" , Michael Kelley , Wei Liu , Sasha Levin Subject: [PATCH 4.19 099/247] Drivers: hv: vmbus: Avoid use-after-free in vmbus_onoffer_rescind() Date: Mon, 1 Mar 2021 17:11:59 +0100 Message-Id: <20210301161036.526403156@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161031.684018251@linuxfoundation.org> References: <20210301161031.684018251@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrea Parri (Microsoft) [ Upstream commit e3fa4b747f085d2cda09bba0533b86fa76038635 ] When channel->device_obj is non-NULL, vmbus_onoffer_rescind() could invoke put_device(), that will eventually release the device and free the channel object (cf. vmbus_device_release()). However, a pointer to the object is dereferenced again later to load the primary_channel. The use-after-free can be avoided by noticing that this load/check is redundant if device_obj is non-NULL: primary_channel must be NULL if device_obj is non-NULL, cf. vmbus_add_channel_work(). Fixes: 54a66265d6754b ("Drivers: hv: vmbus: Fix rescind handling") Reported-by: Juan Vazquez Signed-off-by: Andrea Parri (Microsoft) Reviewed-by: Michael Kelley Link: https://lore.kernel.org/r/20201209070827.29335-5-parri.andrea@gmail.com Signed-off-by: Wei Liu Signed-off-by: Sasha Levin --- drivers/hv/channel_mgmt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c index 7920b0d7e35a7..ac9617671757c 100644 --- a/drivers/hv/channel_mgmt.c +++ b/drivers/hv/channel_mgmt.c @@ -1001,8 +1001,7 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr) vmbus_device_unregister(channel->device_obj); put_device(dev); } - } - if (channel->primary_channel != NULL) { + } else if (channel->primary_channel != NULL) { /* * Sub-channel is being rescinded. Following is the channel * close sequence when initiated from the driveri (refer to -- 2.27.0