lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <692e6a9b-6caa-7c60-d685-6cc951ee9483@nvidia.com>
Date:   Wed, 29 Jul 2020 18:00:10 -0700
From:   John Hubbard <jhubbard@...dia.com>
To:     Souptick Joarder <jrdr.linux@...il.com>,
        <akpm@...ux-foundation.org>
CC:     <jgg@...pe.ca>, <dan.j.williams@...el.com>,
        <gregkh@...uxfoundation.org>, <mchehab+samsung@...nel.org>,
        <linux-kernel@...r.kernel.org>, <dan.carpenter@...cle.com>
Subject: Re: [PATCH v2] drivers/virt/fsl_hypervisor: Correcting error handling
 path

On 7/29/20 12:01 PM, Souptick Joarder wrote:
> First, when memory allocation for sg_list_unaligned failed, there
> is no point of calling put_pages() as we haven't pinned any pages.
> 
> Second, if get_user_pages_fast() failed we should unpinned num_pinned
> pages, no point of checking till num_pages.

Hi Souptick,

For both of the above, the wording "no point" is so overly gentle as
to be misleading. That's because calling put_page() on any pages beyond
num_pinned is a *bug*.

So let's reword that. And let's change the patch subject from "Correcting" to
"fix".

And probably good to add a Fixes: tag, too.

More:

> 
> This will address both.
> 
> Signed-off-by: Souptick Joarder <jrdr.linux@...il.com>
> Reviewed-by: Dan Carpenter <dan.carpenter@...cle.com>
> Cc: John Hubbard <jhubbard@...dia.com>
> ---
> v2:
> 	Added review tag.
> 
>   drivers/virt/fsl_hypervisor.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/virt/fsl_hypervisor.c b/drivers/virt/fsl_hypervisor.c
> index 1b0b11b..ea344d7 100644
> --- a/drivers/virt/fsl_hypervisor.c
> +++ b/drivers/virt/fsl_hypervisor.c
> @@ -157,7 +157,7 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
>   
>   	unsigned int i;
>   	long ret = 0;
> -	int num_pinned; /* return value from get_user_pages() */
> +	int num_pinned = 0; /* return value from get_user_pages() */
>   	phys_addr_t remote_paddr; /* The next address in the remote buffer */
>   	uint32_t count; /* The number of bytes left to copy */
>   
> @@ -293,7 +293,7 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
>   
>   exit:
>   	if (pages) {
> -		for (i = 0; i < num_pages; i++)
> +		for (i = 0; i < num_pinned; i++)
>   			if (pages[i])

I suspect that this "if" is unnecessary now.

Either way, the diff itself looks good to me, so with the wording changes to
the commit description, you can add:

     Reviewed-by: John Hubbard <jhubbard@...dia.com>

thanks,
-- 
John Hubbard
NVIDIA

>   				put_page(pages[i]);
>   	}
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ