Re: [PATCH] ntp: fix bug in adjtimex reading time offset

From: Richard Cochran
Date: Wed Nov 27 2024 - 11:05:24 EST


On Wed, Nov 27, 2024 at 03:10:30PM +0100, Thomas Gleixner wrote:
> On Mon, Nov 25 2024 at 12:16, Marcelo Dalmas wrote:
> > Due to an unsigned cast, adjtimex returns wrong offest when using ADJ_MICRO and the offset is negative.
> > In this case a small negative offset return approximately 4.29 seconds (~ 2^32/1000 milliseconds).
>
> Nice find.

How did this slip in? Git blame tells:

commit ead25417f82ed7f8a21da4dcefc768169f7da884
Author: Deepa Dinamani <deepa.kernel@xxxxxxxxx>
Date: Mon Jul 2 22:44:21 2018 -0700

timex: use __kernel_timex internally

struct timex is not y2038 safe.
Replace all uses of timex with y2038 safe __kernel_timex.

...

The patch was generated by the following coccinelle script:

...

So I guess combining random other manual fixes into a patch that
claims to be generated is a bad idea?

Thanks,
Richard