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:   Thu, 27 Jan 2022 16:01:28 +0000
From:   "Michael Kelley (LINUX)" <mikelley@...rosoft.com>
To:     "Gustavo A. R. Silva" <gustavoars@...nel.org>,
        KY Srinivasan <kys@...rosoft.com>,
        Haiyang Zhang <haiyangz@...rosoft.com>,
        Stephen Hemminger <sthemmin@...rosoft.com>,
        Wei Liu <wei.liu@...nel.org>, Dexuan Cui <decui@...rosoft.com>
CC:     "linux-hyperv@...r.kernel.org" <linux-hyperv@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-hardening@...r.kernel.org" <linux-hardening@...r.kernel.org>
Subject: RE: [PATCH][next] Drivers: hv: vmbus: Use struct_size() helper in
 kmalloc()

From: Gustavo A. R. Silva <gustavoars@...nel.org> Sent: Tuesday, January 25, 2022 10:02 AM
> 
> Make use of the struct_size() helper instead of an open-coded version,
> in order to avoid any potential type mistakes or integer overflows that,
> in the worst scenario, could lead to heap overflows.
> 
> Also, address the following sparse warnings:
> drivers/hv/vmbus_drv.c:1132:31: warning: using sizeof on a flexible structure
> 
> Link: https://github.com/KSPP/linux/issues/174
> ---
>  drivers/hv/vmbus_drv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> index 17bf55fe3169..cd193456cd84 100644
> --- a/drivers/hv/vmbus_drv.c
> +++ b/drivers/hv/vmbus_drv.c
> @@ -1129,7 +1129,7 @@ void vmbus_on_msg_dpc(unsigned long data)
>  	}
> 
>  	if (entry->handler_type	== VMHT_BLOCKING) {
> -		ctx = kmalloc(sizeof(*ctx) + payload_size, GFP_ATOMIC);
> +		ctx = kmalloc(struct_size(ctx, msg.payload, payload_size), GFP_ATOMIC);
>  		if (ctx == NULL)
>  			return;
> 
> --
> 2.27.0

Reviewed-by: Michael Kelley <mikelley@...rosoft.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ