mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jorgen Hansen <jhansen@vmware.com>
To: 'Arnd Bergmann' <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Xiyu Yang <xiyuyang19@fudan.edu.cn>,
	Alexios Zavras <alexios.zavras@intel.com>,
	Allison Randal <allison@lohutok.net>,
	Adit Ranadive <aditr@vmware.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Vishnu Dasa <vdasa@vmware.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"yuanxzhang@fudan.edu.cn" <yuanxzhang@fudan.edu.cn>,
	"kjlu@umn.edu" <kjlu@umn.edu>, Xin Tan <tanxin.ctf@gmail.com>
Subject: RE: [PATCH v2] VMCI: Fix NULL pointer dereference on context ptr
Date: Mon, 23 Mar 2020 10:16:43 +0000	[thread overview]
Message-ID: <MWHPR05MB33760A2F7ABC03DB367B09C2DAF00@MWHPR05MB3376.namprd05.prod.outlook.com> (raw)
In-Reply-To: <CAK8P3a3B373YcmZncnE-wJz12B+3A5QC9CUrDd72qSw+65MwQg@mail.gmail.com>

> From: Arnd Bergmann [mailto:arnd@arndb.de]
> Sent: Monday, March 23, 2020 10:17 AM
> On Mon, Mar 23, 2020 at 9:52 AM Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> >
> > On Mon, Mar 23, 2020 at 04:22:33PM +0800, Xiyu Yang wrote:
> > > A NULL vmci_ctx object may pass to vmci_ctx_put() from its callers.
> >
> > Are you sure this can happen?
> >
> > > Add a NULL check to prevent NULL pointer dereference.
> 
> It looks like this could happen if vmci_ctx_get() returns NULL, which is
> not checked for consistently. Maybe add better error handling to the
> callers that currently don't check for that, to catch problems such as

In the cases, where the return value isn't checked, the return value of
vmci_ctx_get() won't be NULL, as the code won't be reached unless the
context ID has an associated context structure. In the example below,
the caller has obtained the context_id from an active context. That said,
it wouldn't hurt to add either checks or at least a comment as to why
the context won't be NULL in the cases, where it isn't checked today.

> 
> void vmci_ctx_rcv_notifications_release(...)
> {
>         struct vmci_ctx *context = vmci_ctx_get(context_id); /* may be NULL */
>        ...
>        context->pending_doorbell_array = db_handle_array;
>        ...
>        vmci_ctx_put(context);
> }
> 
> Checking only in vmci_ctx_put() is too late.
> 
>      Arnd

Thanks,
Jorgen

  reply	other threads:[~2020-03-23 10:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-23  8:22 Xiyu Yang
2020-03-23  8:52 ` Greg Kroah-Hartman
2020-03-23  9:16   ` Arnd Bergmann
2020-03-23 10:16     ` Jorgen Hansen [this message]
2020-03-29 12:08   ` Xiyu Yang

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=MWHPR05MB33760A2F7ABC03DB367B09C2DAF00@MWHPR05MB3376.namprd05.prod.outlook.com \
    --to=jhansen@vmware.com \
    --cc=aditr@vmware.com \
    --cc=alexios.zavras@intel.com \
    --cc=allison@lohutok.net \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --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

all inboxes | Powered by JetHome®