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]
Date:   Wed, 22 Nov 2017 07:55:41 -0800
From:   Joe Perches <joe@...ches.com>
To:     Vasyl Gomonovych <gomonovych@...il.com>, mingo@...nel.org
Cc:     linux-kernel@...r.kernel.org
Subject: Re: [PATCH] VMCI:  Use memdup_user() as a cleanup

On Wed, 2017-11-22 at 16:29 +0100, Vasyl Gomonovych wrote:
> Fix coccicheck warning which recommends to use memdup_user():
> drivers/misc/vmw_vmci/vmci_host.c:757:11-18: WARNING opportunity for memdup_user
> Generated by: scripts/coccinelle/memdup_user/memdup_user.cocci

Nice little cleanup.

> diff --git a/drivers/misc/vmw_vmci/vmci_host.c b/drivers/misc/vmw_vmci/vmci_host.c
[]
> @@ -754,18 +754,12 @@ static int vmci_host_do_ctx_set_cpt_state(struct vmci_host_dev *vmci_host_dev,
[]
> +	cpt_buf = memdup_user((void __user *)(uintptr_t)set_info.cpt_buf,
> +			set_info.buf_size);
> +	if (IS_ERR(cpt_buf)) {
> +		vmci_ioctl_err("cannot allocate memory to set cpt state (type=%d)\n",
> +				set_info.cpt_type);
> +		return PTR_ERR(cpt_buf);

Trivia:

The vmci_ioctl_err might not be necessary.
There is a dump_stack() on allocation failure.

and

> @@ -774,7 +768,6 @@ static int vmci_host_do_ctx_set_cpt_state(struct vmci_host_dev *vmci_host_dev,
>  
>  	retval = copy_to_user(uptr, &set_info, sizeof(set_info)) ? -EFAULT : 0;
>  
> -out:
>  	kfree(cpt_buf);
>  	return retval;

Perhaps move the kfree above the copy_to_user,
remove the retval declaration and use

	return copy_to_user(uptr, &set_info, sizeof(set_info)) ? -EFAULT : 0;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ