mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Alexander Viro <viro@ZenIV.linux.org.uk>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
	George Zhang <georgezhang@vmware.com>,
	Andy king <acking@vmware.com>, Dmitry Torokhov <dtor@vmware.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH 1/1] Fix: vmw_vmci driver get_user_pages_fast error handling
Date: Thu, 2 Nov 2017 18:54:11 +0000 (UTC)	[thread overview]
Message-ID: <1101795050.2326.1509648851686.JavaMail.zimbra@efficios.com> (raw)
In-Reply-To: <20171102184612.GL21978@ZenIV.linux.org.uk>

----- On Nov 2, 2017, at 2:46 PM, Alexander Viro viro@ZenIV.linux.org.uk wrote:

> On Tue, Oct 31, 2017 at 07:00:38PM -0400, Mathieu Desnoyers wrote:
>> Comparing a signed return value against an unsigned num_pages
>> field performs the comparison as "unsigned", and therefore mistakenly
>> considers get_user_pages_fast() errors as success.
> 
> It's worse than that - if you look into the code in question you'll
> see
>                pr_debug("get_user_pages_fast(produce) failed (retval=%d)",
>                        retval);
>                qp_release_pages(produce_q->kernel_if->u.h.header_page,
>                                 retval, false);
>                err = VMCI_ERROR_NO_MEM;
>                goto out;
> with
> static void qp_release_pages(struct page **pages,
>                             u64 num_pages, bool dirty)
> {
>        int i;
> 
>        for (i = 0; i < num_pages; i++) {
>                if (dirty)
>                        set_page_dirty(pages[i]);
> 
>                put_page(pages[i]);
>                pages[i] = NULL;
>        }
> }
> 
> Now, guess what'll happen if you get there with retval being negative?

Well this ought to be a pretty long loop...

> AFAICS, the right fix is something along the lines of
>        if (retval != produce_q->kernel_if->num_pages) {
>                pr_debug("get_user_pages_fast(produce) failed (retval=%d)",
>                        retval);
>		if (retval > 0)
>			qp_release_pages(produce_q->kernel_if->u.h.header_page,
>					 retval, false);
>                err = VMCI_ERROR_NO_MEM;
>                goto out;
>        }
> and similar for the second caller.  Objections?

No objection from me,

Thanks!

Mathieu


-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

      reply	other threads:[~2017-11-02 18:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-31 23:00 Mathieu Desnoyers
2017-11-02 18:46 ` Al Viro
2017-11-02 18:54   ` Mathieu Desnoyers [this message]

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=1101795050.2326.1509648851686.JavaMail.zimbra@efficios.com \
    --to=mathieu.desnoyers@efficios.com \
    --cc=acking@vmware.com \
    --cc=dtor@vmware.com \
    --cc=georgezhang@vmware.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@ZenIV.linux.org.uk \
    /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

Powered by JetHome