From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Cc: Arnd Bergmann <arnd@arndb.de>, Xin Tan <tanxin.ctf@gmail.com>,
Alexios Zavras <alexios.zavras@intel.com>,
Vishnu DASA <vdasa@vmware.com>,
Thomas Gleixner <tglx@linutronix.de>,
Allison Randal <allison@lohutok.net>,
Ira Weiny <ira.weiny@intel.com>,
Mike Marshall <hubcap@omnibond.com>,
linux-kernel@vger.kernel.org, yuanxzhang@fudan.edu.cn,
kjlu@umn.edu
Subject: Re: [PATCH] VMCI: Fix NULL pointer dereference on context ptr
Date: Wed, 18 Mar 2020 12:02:04 +0100 [thread overview]
Message-ID: <20200318110204.GB2305113@kroah.com> (raw)
In-Reply-To: <1584426607-89366-1-git-send-email-xiyuyang19@fudan.edu.cn>
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 <xiyuyang19@fudan.edu.cn>
> Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
> ---
> 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?
>
> spin_lock(&context->lock);
> if (!success) {
> diff --git a/drivers/misc/vmw_vmci/vmci_queue_pair.c b/drivers/misc/vmw_vmci/vmci_queue_pair.c
> index 8531ae781195..2ecb22d08692 100644
> --- a/drivers/misc/vmw_vmci/vmci_queue_pair.c
> +++ b/drivers/misc/vmw_vmci/vmci_queue_pair.c
> @@ -1575,11 +1575,14 @@ static int qp_broker_attach(struct qp_broker_entry *entry,
> */
>
> create_context = vmci_ctx_get(entry->create_id);
> - supports_host_qp = vmci_ctx_supports_host_qp(create_context);
> - vmci_ctx_put(create_context);
> + if (!create_context) {
> + supports_host_qp =
> + vmci_ctx_supports_host_qp(create_context);
> + vmci_ctx_put(create_context);
>
> - if (!supports_host_qp)
> - return VMCI_ERROR_INVALID_RESOURCE;
> + if (!supports_host_qp)
> + return VMCI_ERROR_INVALID_RESOURCE;
> + }
> }
>
> if ((entry->qp.flags & ~VMCI_QP_ASYMM) != (flags & ~VMCI_QP_ASYMM_PEER))
> @@ -1808,7 +1811,8 @@ static int qp_alloc_host_work(struct vmci_handle *handle,
> pr_devel("queue pair broker failed to alloc (result=%d)\n",
> result);
> }
> - vmci_ctx_put(context);
> + if (context)
> + vmci_ctx_put(context);
can't vmci_ctx_put() take a NULL pointer? If not, fix this that way
please.
thanks,
greg k-h
next prev parent reply other threads:[~2020-03-18 11:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-17 6:29 [PATCH] VMCI: Fix NULL pointer dereference on context ptr Xiyu Yang
2020-03-18 11:02 ` Greg Kroah-Hartman [this message]
2020-03-23 4:53 ` Xiyu Yang
2020-03-23 6:55 ` Greg Kroah-Hartman
2020-03-23 9:20 ` Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200318110204.GB2305113@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=alexios.zavras@intel.com \
--cc=allison@lohutok.net \
--cc=arnd@arndb.de \
--cc=hubcap@omnibond.com \
--cc=ira.weiny@intel.com \
--cc=kjlu@umn.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=tanxin.ctf@gmail.com \
--cc=tglx@linutronix.de \
--cc=vdasa@vmware.com \
--cc=xiyuyang19@fudan.edu.cn \
--cc=yuanxzhang@fudan.edu.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox