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: <060a134b-63ea-4dc1-a5f3-980b2bb4334f@lunn.ch>
Date: Wed, 25 Sep 2024 17:39:37 +0200
From: Andrew Lunn <andrew@...n.ch>
To: George Rurikov <g.ryurikov@...uritycode.ru>
Cc: Heiner Kallweit <hkallweit1@...il.com>, nic_swsd@...ltek.com,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
	netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
	stable@...r.kernel.org
Subject: Re: [PATCH] r8169: Potential divizion by zero in rtl_set_coalesce()

On Wed, Sep 25, 2024 at 04:51:06PM +0300, George Rurikov wrote:
> Variable 'scale', whose possible value set allows a zero value in a check
> at r8169_main.c:2014, is used as a denominator at r8169_main.c:2040 and
> r8169_main.c:2042.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: 2815b30535a0 ("r8169: merge scale for tx and rx irq coalescing")
> Cc: stable@...r.kernel.org
> Signed-off-by: George Rurikov <g.ryurikov@...uritycode.ru>
> ---
>  drivers/net/ethernet/realtek/r8169_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
> index 45ac8befba29..b97e68cfcfad 100644
> --- a/drivers/net/ethernet/realtek/r8169_main.c
> +++ b/drivers/net/ethernet/realtek/r8169_main.c
> @@ -2011,7 +2011,7 @@ static int rtl_set_coalesce(struct net_device *dev,
> 
>         coal_usec_max = max(ec->rx_coalesce_usecs, ec->tx_coalesce_usecs);
>         scale = rtl_coalesce_choose_scale(tp, coal_usec_max, &cp01);
> -       if (scale < 0)
> +       if (scale <= 0)
>                 return scale;

Please think about this. Say scale is 0, and you return it. It appears
the call has worked, but in fact it did nothing.

I much prefer a division by 0, causing a splat, than the silent bug
you just added.

Also, please could you explain the code path which results in scale
being 0.

    Andrew

---
pw-bot: cr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ