Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3406660ybb; Sun, 22 Mar 2020 23:56:52 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtIwRiflSYfOPv0JVNH4E5PsJqwWZ++tMpzMLO5ouHJCHBCexYGhPMuPfPu/qWSXf6fq3d7 X-Received: by 2002:a05:6830:22c3:: with SMTP id q3mr16267462otc.212.1584946612075; Sun, 22 Mar 2020 23:56:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584946612; cv=none; d=google.com; s=arc-20160816; b=z+bvgstKYvl1QW8VwE0dtlsZ/30dc9LBQpr6/R21+CFpUX8ViClK7UmMn1w/Ke5N3b e8AKVJP/Qou8L1Ms8HgZXc9BzUTBI11MKnl3OXhLUYLgDijBxAeOwcB69bXBMYib/oYH VRbLBSiOz8yTfSljhIFbqKt3RZHtmaRtE0ifsKpKMcrfpou0BFXWpX9iEpg2zGtvmOjN 35gAo5jKSZ0THjba/CwDEyrzgNlVjLj4wHJw2AnJTSNJKcnNleVLknzDIF2MwXG6XM4z /f8nuRcRVcHeGUk6BuCHOpJVk2rMwFpnc3xrxtbjHh0ys5frGT/8dI+pYa76C1ZQg8wq +Obg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=BuXtjgD8ygVkg2c1gBBXiL90OVxtzc0NoQY5kEdLh3U=; b=NyCeRkZLs7BCR5lPLxaD3sJPEdCVGKiKHHxBS0VxGPFAcaRgQy6stY2Vn6yJY4QtU5 9HGTAjM5GNsJZQcrccMf6jCuXJ9FpG+BmN9oR9Ntl1ksx3GwWwU/Mnx+VSMCm5JxLIv3 EUeLJw9JuWexbLSDTdAbLaNMJZOmKFelrW263D7A9G/WEhqbFsF9HJw3gVgbXz0Om3kX RCcOoSrxuIqu/CJdJaZ3nxAI4T27eoFTXN7q6YewRWe48VewsJf3Z9vGiHrYYHI7pxW8 npUGzzxrvm2ZeOaZrLbtj+yzd+XUGiOtFTy1YQJvYuyFfD561G7DHfk4oQWlzSeVLFIH W2pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=K0xL1w2a; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e7si7929870oti.301.2020.03.22.23.56.39; Sun, 22 Mar 2020 23:56:52 -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=K0xL1w2a; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727351AbgCWGzK (ORCPT + 99 others); Mon, 23 Mar 2020 02:55:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:51038 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727164AbgCWGzK (ORCPT ); Mon, 23 Mar 2020 02:55:10 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DD4E120736; Mon, 23 Mar 2020 06:55:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584946508; bh=lrWhTzB6xgIB0JiiTBsh5jvnmI6j4FZbM7p/RbCrzdg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=K0xL1w2abErjmfCO1gQbf2yVoe+9vnOyllcISy8RQNWW9Ula0pSdZqnewZur8OlCL Yab5JpM62US0Ur6+36zRL8uOo8qVYBkwZB3rzHTcrn1ESlRfp97FpP6NIzj461VNlu IXWLq7DK3mDmhlpvQh+/wkEWZjQRuHgoB6CbgFDM= Date: Mon, 23 Mar 2020 07:55:06 +0100 From: Greg Kroah-Hartman To: Xiyu Yang Cc: Arnd Bergmann , Xin Tan , Alexios Zavras , Vishnu DASA , Thomas Gleixner , Allison Randal , Ira Weiny , Mike Marshall , linux-kernel@vger.kernel.org, yuanxzhang@fudan.edu.cn, kjlu@umn.edu Subject: Re: Re: [PATCH] VMCI: Fix NULL pointer dereference on context ptr Message-ID: <20200323065506.GA131098@kroah.com> References: <1584426607-89366-1-git-send-email-xiyuyang19@fudan.edu.cn> <20200318110204.GB2305113@kroah.com> <20200323045302.GA117440@sherlly> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200323045302.GA117440@sherlly> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 23, 2020 at 12:53:02PM +0800, Xiyu Yang wrote: > Hi Greg, > > On Wed, Mar 18, 2020 at 12:02:04PM +0100, Greg Kroah-Hartman wrote: > > On Tue, Mar 17, 2020 at 02:29:57PM +0800, Xiyu Yang wrote: > > > The refcount wrapper function vmci_ctx_get() may return NULL > > > context ptr. Thus, we need to add a NULL pointer check > > > before its dereference. > > > > > > Signed-off-by: Xiyu Yang > > > Signed-off-by: Xin Tan > > > --- > > > drivers/misc/vmw_vmci/vmci_context.c | 2 ++ > > > drivers/misc/vmw_vmci/vmci_queue_pair.c | 17 +++++++++++------ > > > 2 files changed, 13 insertions(+), 6 deletions(-) > > > > > > diff --git a/drivers/misc/vmw_vmci/vmci_context.c b/drivers/misc/vmw_vmci/vmci_context.c > > > index 16695366ec92..a20878fba374 100644 > > > --- a/drivers/misc/vmw_vmci/vmci_context.c > > > +++ b/drivers/misc/vmw_vmci/vmci_context.c > > > @@ -898,6 +898,8 @@ void vmci_ctx_rcv_notifications_release(u32 context_id, > > > bool success) > > > { > > > struct vmci_ctx *context = vmci_ctx_get(context_id); > > > + if (context == NULL) > > > + return; > > > > Same comment as on your other patch. > > > > And is this a v2? > > Thanks! Yes, this is a v2. > > According to our observation, vmci_ctx_rcv_notifications_release() > currently is only called by vmci_host_do_recv_notifications() which > guarantees a valid context object can be acquired with this context_id. > > However, we argue that a NULL-check here is still necessary because > this function may be called by other functions in the future who may > fail/forget to provide such guarantee. No, that's not how we write code in the kernel, if it does not need to be checked for because this can not happen, then do not check for it. Don't try to plan for random users of your code in the future when you control those users directly :) thanks, greg k-h