Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2043972pxu; Tue, 24 Nov 2020 15:41:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJzC+LpUffa+u5m93TB1ps8d1afUdcygAySPDB3BHq6rQMSvWlDJ7nlV/GGHwmlA+7+xl3sP X-Received: by 2002:a17:906:5f92:: with SMTP id a18mr738631eju.397.1606261266991; Tue, 24 Nov 2020 15:41:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606261266; cv=none; d=google.com; s=arc-20160816; b=ZqVaQd7OiYpKp2QCAsj55PMgQyE7HrVKS5XeDFUq/pxKSzPQUgG33utrxhFEJGN6IP AB7hh3E2Phpj2qzXXrU1wtgEuFdXzSR9aRiNh6WvjjsKKnSqAgKQglaXFMNqWYzttTRv 4W+Tb+BT/+O/s6dznbAxKE2AIiDLo+RUt+chjVj/l87JGGS+/2MsF6Rqh/CLwvAzyy6+ SB3yVqmfAgTH/DNSbk2KzeU5ShdjurkDJZfw+Qr6n81przE/p0I9/foqJuYosBo8yz6G MI44ciXjzQMwiYL1uEVw92UJ4zMgiw/kXONM9Ip/j9GLZ2HAakxG9aNvPgZagCwe4vlK /OWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=eRGc6PGD/C/bb7eassDLJxbAFdnZyH0+sgdit1sSu7c=; b=pZl9n+0kQl/9IToU15YLEXunBemumh138ENxqvnV5i3Xz1WirXgSENgxKZxMOfgpAD XoRj0Dj6+qY0EDJe8VXrwVMvaIsLYPFvHXD69AtK4Py2yRqCe60BSQp8VPzXCS/6iDqn pEKqj65UbK3SXxjGZMIq8DpDCLE9naxX0Bsv2O4fZBmrTT6Q8nj7z7ns5dN2uxEHF+bO ck5GMo5Ex/rvje3Xu0HQGIW9GvQVgoDERLloNK30PwyQbxwHXP/tjaXirzpxa3cxtFRq ZMsfQxgYEQdB7uljIUZZE3AxFM/Vy7aIfjeHopCcX5u+G3WgAWPAqggp4Gc9/3es1QWt 2b+Q== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn6si227518ejc.234.2020.11.24.15.40.43; Tue, 24 Nov 2020 15:41:06 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390435AbgKXQ0i (ORCPT + 99 others); Tue, 24 Nov 2020 11:26:38 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:52369 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389861AbgKXQ0h (ORCPT ); Tue, 24 Nov 2020 11:26:37 -0500 Received: by mail-wm1-f65.google.com with SMTP id 10so2928282wml.2; Tue, 24 Nov 2020 08:26:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=eRGc6PGD/C/bb7eassDLJxbAFdnZyH0+sgdit1sSu7c=; b=fntC3gNHkrSx9Y9gWslR8g8j/+P/RyW544+EHH+AFIgJbPkwIeMLcbanwDnPG/FIBv 8btW0EqDXP08rn0zHqteRmmPEqbflqPyhK2wTT5le4wuO4JQwZYAHBcpTJ3lELKo9Luc vsFfyjS14YjCgRC0pqnx6x+v3rFPtAxabSz+Ft3XAf3on0cpT1WY91XbOQyHoaJMPm6k fcRhFuzqRj0llVUp3cpcrE/sFXANaEnc1KgqTAXvDu+zGoTAl38wP+UOChoUt6k59V4X 6xZ1ADhM31AXeQwENh7aAD8eHv1vPY9kZKzN6SDtlB1jlaG8/JNFWPjldThxNPhn+6Tv MD5A== X-Gm-Message-State: AOAM532WOXDOOe/iWofXa8zFib0Zsc1hcXJUwKI5URVrIG+X3z6HCnb9 9vmt++QU15iTuKS1yvI/l7Y= X-Received: by 2002:a1c:328a:: with SMTP id y132mr5299762wmy.134.1606235195537; Tue, 24 Nov 2020 08:26:35 -0800 (PST) Received: from liuwe-devbox-debian-v2 ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id c187sm7425248wmd.23.2020.11.24.08.26.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Nov 2020 08:26:35 -0800 (PST) Date: Tue, 24 Nov 2020 16:26:33 +0000 From: Wei Liu To: "Andrea Parri (Microsoft)" Cc: linux-kernel@vger.kernel.org, "K . Y . Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , linux-hyperv@vger.kernel.org, Michael Kelley , Juan Vazquez , Saruhan Karademir Subject: Re: [PATCH 4/6] Drivers: hv: vmbus: Avoid use-after-free in vmbus_onoffer_rescind() Message-ID: <20201124162633.n7zlpte6f7zfhn6z@liuwe-devbox-debian-v2> References: <20201118143649.108465-1-parri.andrea@gmail.com> <20201118143649.108465-5-parri.andrea@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201118143649.108465-5-parri.andrea@gmail.com> User-Agent: NeoMutt/20180716 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 18, 2020 at 03:36:47PM +0100, Andrea Parri (Microsoft) wrote: > 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_obk is non-NULL: primary_channel must be NULL if device_obk -> device_obj > device_obj is non-NULL, cf. vmbus_add_channel_work(). > Missing a Fixes tag? > Reported-by: Juan Vazquez > Signed-off-by: Andrea Parri (Microsoft) > --- > 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 5bc5eef5da159..4072fd1f22146 100644 > --- a/drivers/hv/channel_mgmt.c > +++ b/drivers/hv/channel_mgmt.c > @@ -1116,8 +1116,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.25.1 >