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] [day] [month] [year] [list]
Message-ID: <CAMuHMdUoZSXQwu6gZgbzUcFgjQh=ng7UZAGC5ke4GVB-zqqhqQ@mail.gmail.com>
Date: Thu, 8 May 2025 10:08:05 +0200
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Tigran Sogomonian <tsogomonian@...ralinux.ru>
Cc: Michael Turquette <mturquette@...libre.com>, Stephen Boyd <sboyd@...nel.org>, 
	linux-renesas-soc@...r.kernel.org, linux-clk@...r.kernel.org, 
	linux-kernel@...r.kernel.org, lvc-project@...uxtesting.org
Subject: Re: [PATCH RFC] renesas: add zero check for prate variable

Hi Tigran,

On Thu, 27 Mar 2025 at 16:13, Tigran Sogomonian
<tsogomonian@...ralinux.ru> wrote:
> To avoid division by zero, a check was added to the prate
> variable, since no guarantees were found that it could not
> be equal to zero.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Signed-off-by: Tigran Sogomonian <tsogomonian@...ralinux.ru>

Thanks for your patch!

> --- a/drivers/clk/renesas/rcar-gen3-cpg.c
> +++ b/drivers/clk/renesas/rcar-gen3-cpg.c
> @@ -205,6 +205,8 @@ static int cpg_z_clk_determine_rate(struct clk_hw *hw,
>                                                   prate * zclk->fixed_div);
>
>         prate = req->best_parent_rate / zclk->fixed_div;
> +       if (prate == 0)
> +               return -EINVAL;

prate can never be zero, as req->best_parent_rate is always larger or
equal than zclk->max_rate, and zclk->fixed_div is a very small number
(2 or 4).

>         min_mult = max(div64_ul(req->min_rate * 32ULL, prate), 1ULL);
>         max_mult = min(div64_ul(req->max_rate * 32ULL, prate), 32ULL);
>         if (max_mult < min_mult)
> diff --git a/drivers/clk/renesas/rcar-gen4-cpg.c b/drivers/clk/renesas/rcar-gen4-cpg.c
> index 31aa790fd003..4c9a7d699290 100644
> --- a/drivers/clk/renesas/rcar-gen4-cpg.c
> +++ b/drivers/clk/renesas/rcar-gen4-cpg.c
> @@ -308,6 +308,8 @@ static int cpg_z_clk_determine_rate(struct clk_hw *hw,
>                                                   prate * zclk->fixed_div);
>
>         prate = req->best_parent_rate / zclk->fixed_div;
> +       if (prate == 0)
> +               return -EINVAL;

Likewise.

>         min_mult = max(div64_ul(req->min_rate * 32ULL, prate), 1ULL);
>         max_mult = min(div64_ul(req->max_rate * 32ULL, prate), 32ULL);
>         if (max_mult < min_mult)

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ