[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1101795050.2326.1509648851686.JavaMail.zimbra@efficios.com>
Date: Thu, 2 Nov 2017 18:54:11 +0000 (UTC)
From: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
To: Alexander Viro <viro@...IV.linux.org.uk>
Cc: linux-kernel <linux-kernel@...r.kernel.org>,
George Zhang <georgezhang@...are.com>,
Andy king <acking@...are.com>,
Dmitry Torokhov <dtor@...are.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-fsdevel <linux-fsdevel@...r.kernel.org>
Subject: Re: [PATCH 1/1] Fix: vmw_vmci driver get_user_pages_fast error
handling
----- On Nov 2, 2017, at 2:46 PM, Alexander Viro viro@...IV.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
Powered by blists - more mailing lists