[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK8P3a02a=rqQdxrWPhKsNkdj8r0p-nR8Cf+fgwFTEY5WHGr9g@mail.gmail.com>
Date: Mon, 25 Feb 2019 15:19:10 +0100
From: Arnd Bergmann <arnd@...db.de>
To: Deepa Dinamani <deepa.kernel@...il.com>
Cc: Hongbo Yao <yaohongbo@...wei.com>,
Thomas Gleixner <tglx@...utronix.de>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Linuxarm <linuxarm@...wei.com>
Subject: Re: [PATCH] time64: Avoid undefined behaviour in timespec64_add()
On Mon, Feb 25, 2019 at 10:07 AM Arnd Bergmann <arnd@...db.de> wrote:
> On Mon, Feb 25, 2019 at 10:01 AM Arnd Bergmann <arnd@...db.de> wrote:
> > On Mon, Feb 25, 2019 at 5:53 AM Deepa Dinamani <deepa.kernel@...il.com> wrote:
> > > On Sun, Feb 24, 2019 at 7:13 PM Hongbo Yao <yaohongbo@...wei.com> wrote:
>
> diff --git a/drivers/net/ethernet/cadence/macb_ptp.c
> b/drivers/net/ethernet/cadence/macb_ptp.c
> index a6dc47edc4cf..0d5ebde29c0d 100644
> --- a/drivers/net/ethernet/cadence/macb_ptp.c
> +++ b/drivers/net/ethernet/cadence/macb_ptp.c
> @@ -160,7 +160,7 @@ static int gem_ptp_adjfine(struct ptp_clock_info
> *ptp, long scaled_ppm)
> static int gem_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
> {
> struct macb *bp = container_of(ptp, struct macb, ptp_clock_info);
> - struct timespec64 now, then = ns_to_timespec64(delta);
> + struct timespec64 now;
> u32 adj, sign = 0;
>
> if (delta < 0) {
> @@ -170,7 +170,7 @@ static int gem_ptp_adjtime(struct ptp_clock_info
> *ptp, s64 delta)
>
> if (delta > TSU_NSEC_MAX_VAL) {
> gem_tsu_get_time(&bp->ptp_clock_info, &now);
> - now = timespec64_add(now, then);
> + now = timespec64_add(now, ns_to_timespec64(delta));
>
> gem_tsu_set_time(&bp->ptp_clock_info,
> (const struct timespec64 *)&now);
This part of of course completely bogus, I had first changed it
to timespec64_add_ns() for testing, and then back. Please ignore.
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_ptp.c
> b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
> index 5fb4353c742b..4efcba0252a4 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_ptp.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
> @@ -151,7 +151,7 @@ static int i40e_ptp_adjtime(struct ptp_clock_info
> *ptp, s64 delta)
> mutex_lock(&pf->tmreg_lock);
>
> i40e_ptp_read(pf, &now, NULL);
> - timespec64_add_ns(&now, delta);
> + timespec64_add_ns(&now, ns_to_timespec64(delta));
> i40e_ptp_write(pf, (const struct timespec64 *)&now);
>
> mutex_unlock(&pf->tmreg_lock);
>
I think this is still needed, I've added this to my y2038 backlog
and will send a patch for it eventually.
Arnd
Powered by blists - more mailing lists