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: <458526dc-9489-462c-b54f-3854b9227cb6@intel.com>
Date: Mon, 17 Jun 2024 14:56:21 +0200
From: Wojciech Drewek <wojciech.drewek@...el.com>
To: Dan Carpenter <dan.carpenter@...aro.org>, Yangbo Lu <yangbo.lu@....com>
CC: Richard Cochran <richardcochran@...il.com>, "David S. Miller"
	<davem@...emloft.net>, <netdev@...r.kernel.org>,
	<linux-kernel@...r.kernel.org>, <kernel-janitors@...r.kernel.org>,
	"Christophe JAILLET" <christophe.jaillet@...adoo.fr>
Subject: Re: [PATCH v2 net] ptp: fix integer overflow in max_vclocks_store



On 17.06.2024 11:34, Dan Carpenter wrote:
> On 32bit systems, the "4 * max" multiply can overflow.  Use kcalloc()
> to do the allocation to prevent this.
> 
> Fixes: 44c494c8e30e ("ptp: track available ptp vclocks information")
> Signed-off-by: Dan Carpenter <dan.carpenter@...aro.org>
> ---

Thx,
Reviewed-by: Wojciech Drewek <wojciech.drewek@...el.com>

> v2: It's better to use kcalloc() instead of size_mul().
> 
>  drivers/ptp/ptp_sysfs.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c
> index a15460aaa03b..6b1b8f57cd95 100644
> --- a/drivers/ptp/ptp_sysfs.c
> +++ b/drivers/ptp/ptp_sysfs.c
> @@ -296,8 +296,7 @@ static ssize_t max_vclocks_store(struct device *dev,
>  	if (max < ptp->n_vclocks)
>  		goto out;
>  
> -	size = sizeof(int) * max;
> -	vclock_index = kzalloc(size, GFP_KERNEL);
> +	vclock_index = kcalloc(max, sizeof(int), GFP_KERNEL);
>  	if (!vclock_index) {
>  		err = -ENOMEM;
>  		goto out;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ