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: <20210325102620.GA121097@roeck-us.net>
Date:   Thu, 25 Mar 2021 03:26:20 -0700
From:   Guenter Roeck <linux@...ck-us.net>
To:     Yangbo Lu <yangbo.lu@....com>
Cc:     netdev@...r.kernel.org, Richard Cochran <richardcochran@...il.com>
Subject: Re: [PATCH] ptp_qoriq: fix overflow in ptp_qoriq_adjfine() u64
 calcalation

On Thu, Mar 25, 2021 at 03:23:07AM -0700, Guenter Roeck wrote:
> On Tue, Mar 23, 2021 at 04:02:29PM +0800, Yangbo Lu wrote:
> > Current calculation for diff of TMR_ADD register value may have
> > 64-bit overflow in this code line, when long type scaled_ppm is
> > large.
> > 
> > adj *= scaled_ppm;
> > 
> > This patch is to resolve it by using mul_u64_u64_div_u64().
> > 
> > Signed-off-by: Yangbo Lu <yangbo.lu@....com>
> > Acked-by: Richard Cochran <richardcochran@...il.com>
> > ---
> >  drivers/ptp/ptp_qoriq.c | 13 +++++++------
> >  1 file changed, 7 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/ptp/ptp_qoriq.c b/drivers/ptp/ptp_qoriq.c
> > index 68beb1bd07c0..f7f220700cb5 100644
> > --- a/drivers/ptp/ptp_qoriq.c
> > +++ b/drivers/ptp/ptp_qoriq.c
> > @@ -189,15 +189,16 @@ int ptp_qoriq_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
> >  	tmr_add = ptp_qoriq->tmr_add;
> >  	adj = tmr_add;
> >  
> > -	/* calculate diff as adj*(scaled_ppm/65536)/1000000
> > -	 * and round() to the nearest integer
> > +	/*
> > +	 * Calculate diff and round() to the nearest integer
> > +	 *
> > +	 * diff = adj * (ppb / 1000000000)
> > +	 *      = adj * scaled_ppm / 65536000000
> >  	 */
> > -	adj *= scaled_ppm;
> > -	diff = div_u64(adj, 8000000);
> > -	diff = (diff >> 13) + ((diff >> 12) & 1);
> > +	diff = mul_u64_u64_div_u64(adj, scaled_ppm, 32768000000);
> 
> mul_u64_u64_div_u64() is not exported. As result, every build with
> CONFIG_PTP_1588_CLOCK_QORIQ=m (ie every allmodconfig build) fails with:
> 
> ERROR: modpost: "mul_u64_u64_div_u64" [drivers/ptp/ptp-qoriq.ko] undefined!
> 
> or a similar error.
> 
Ah, never mind. I see this is fixed in mainline (export added).
I see the problem in pending-fixes and in next-20210325.

Sorry for the noise.

Guenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ