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  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:   Sun, 9 Aug 2020 22:44:25 +0300
From:   Dmitry Osipenko <digetx@...il.com>
To:     Michał Mirosław <mirq-linux@...e.qmqm.pl>,
        Liam Girdwood <lgirdwood@...il.com>,
        Mark Brown <broonie@...nel.org>
Cc:     linux-kernel@...r.kernel.org
Subject: Re: [PATCH] regulator: fix pointer table overallocation

09.08.2020 22:21, Michał Mirosław пишет:
> The code allocates sizeof(regulator_dev) for a pointer. Make it less
> generous. Let kcalloc() calculate the size, while at it.
> 
> Cc: stable@...r.kernel.org
> Fixes: d8ca7d184b33 ("regulator: core: Introduce API for regulators coupling customization")
> Signed-off-by: Michał Mirosław <mirq-linux@...e.qmqm.pl>
> ---
>  drivers/regulator/core.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
> index 75ff7c563c5d..9e18997777d3 100644
> --- a/drivers/regulator/core.c
> +++ b/drivers/regulator/core.c
> @@ -5011,20 +5011,20 @@ static void regulator_remove_coupling(struct regulator_dev *rdev)
>  
>  static int regulator_init_coupling(struct regulator_dev *rdev)
>  {
> +	struct regulator_dev **coupled;
>  	int err, n_phandles;
> -	size_t alloc_size;
>  
>  	if (!IS_ENABLED(CONFIG_OF))
>  		n_phandles = 0;
>  	else
>  		n_phandles = of_get_n_coupled(rdev);
>  
> -	alloc_size = sizeof(*rdev) * (n_phandles + 1);
> -
> -	rdev->coupling_desc.coupled_rdevs = kzalloc(alloc_size, GFP_KERNEL);
> -	if (!rdev->coupling_desc.coupled_rdevs)
> +	coupled = kcalloc(n_phandles + 1, sizeof(*coupled), GFP_KERNEL);
> +	if (!coupled)
>  		return -ENOMEM;
>  
> +	rdev->coupling_desc.coupled_rdevs = coupled;
> +
>  	/*
>  	 * Every regulator should always have coupling descriptor filled with
>  	 * at least pointer to itself.
> 

Hello, Michał! Thank you for the patch! Not sure whether it's worthwhile
to backport this change since it's an improvement, I'll leave it to Mark
to decide, otherwise looks good to me.

Reviewed-by: Dmitry Osipenko <digetx@...il.com>

Powered by blists - more mailing lists