mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Michael Kerrisk" <mtk.manpages@googlemail.com>
To: "john stultz" <johnstul@us.ibm.com>
Cc: "Michael Kerrisk" <mtk.manpages@gmail.com>,
	"Roman Zippel" <zippel@linux-m68k.org>,
	lkml <linux-kernel@vger.kernel.org>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Ingo Molnar" <mingo@elte.hu>
Subject: Re: ADJ_OFFSET_SS_READ bug?
Date: Mon, 21 Jul 2008 12:36:56 +0200	[thread overview]
Message-ID: <cfd18e0f0807210336q3fa1102cq46708449af86a428@mail.gmail.com> (raw)
In-Reply-To: <cfd18e0f0806301830s7193c340k1dc857885cfc7803@mail.gmail.com>

On Tue, Jul 1, 2008 at 3:30 AM, Michael Kerrisk
<mtk.manpages@googlemail.com> wrote:
> On Tue, Jul 1, 2008 at 12:07 AM, john stultz <johnstul@us.ibm.com> wrote:
>>
>> On Sun, 2008-06-22 at 09:32 +0200, Michael Kerrisk wrote:
>>> Roman, John
>>>
>>> John, thanks for ADJ_OFFSET_SS_READ, which fixed my bug report
>>> (http://sourceware.org/bugzilla/show_bug?id=2449,
>>> http://bugzilla.kernel.org/show_bug.cgi?id=6761)
>>>
>>> Roman, thanks for fixing John's fix ;-)
>>>
>>> However, I'm wondering if there is a potential bug in the
>>> implementation of this flag.  Note the following definitions
>>> from include/linux/timex.h:
>>>
>>> #define ADJ_OFFSET              0x0001  /* time offset */
>>> [...]
>>> #define ADJ_OFFSET_SINGLESHOT   0x8001  /* old-fashioned adjtime */
>>> #define ADJ_OFFSET_SS_READ      0xa001  /* read-only adjtime */
>>>
>>>
>>> Using the the above value for ADJ_OFFSET_SS_READ, where the bits match those
>>> in ADJ_OFFSET and ADJ_OFFSET_SINGLESHOT, seems unnecessary as far as I can
>>> see.  Why was that done?
>>
>> Hrm. My original fix was to use 0x2000, but from the commit Ingo changed
>> it at Ulrich's suggestion. Had something to do with old glibc's doing
>> the right thing?
>>
>>> More to the point, it looks like it creates a bug, since the "read-only
>>> adjtime" triggers the code path for ADJ_OFFSET:
>>>
>>>          if (txc->modes) {
>>>                  ...
>>>                  if (txc->modes & ADJ_OFFSET) {
>>>                          if (txc->modes == ADJ_OFFSET_SINGLESHOT)
>>>                                  /* adjtime() is independent from ntp_adjtime() */
>>>                                  time_adjust = txc->offset;
>>>                          else
>>>                                  ntp_update_offset(txc->offset); /*XXX*/
>>>                  }
>>>                  if (txc->modes & ADJ_TICK)
>>>                          tick_usec = txc->tick;
>>>
>>>                  if (txc->modes & (ADJ_TICK|ADJ_FREQUENCY|ADJ_OFFSET))
>>>                          ntp_update_frequency(); /*XXX*/
>>>          }
>>>
>>> Unless I misunderstood something, ADJ_OFFSET_SS_READ causes the code marked
>>> XXX to be executed, but I don't think that is what is desired.  Is that true?
>>
>> Yea. That does look like an issue. Thanks for the close inspection and
>> review!
>
> You're welcome -- thanks for getting back to me (I was beginning to
> wonder if my mail got dropped somewhere)/
>
>> Sort of a quick off the cuff patch, but does the following look like the
>> right fix to you?
>
> I haven't tested this, but given your statement about maintaining old
> glibc behavior, this looks like the riht fix, so:
>
> Acked-by: Michael Kerrisk <mtk.manpages@gmail.com>


John,

Are you pushing this into 2.6.27-rc1?

Cheers,

Michael

>> Roman: your thoughts?
>>
>>
>> Signed-off-by: John Stultz <johnstul@us.ibm.com>
>>
>> diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
>> index 5125ddd..7842a8d 100644
>> --- a/kernel/time/ntp.c
>> +++ b/kernel/time/ntp.c
>> @@ -379,13 +379,14 @@ int do_adjtimex(struct timex *txc)
>>                        if (txc->modes == ADJ_OFFSET_SINGLESHOT)
>>                                /* adjtime() is independent from ntp_adjtime() */
>>                                time_adjust = txc->offset;
>> -                       else
>> +                       else if (txc->modes != ADJ_OFFSET_SS_READ)
>>                                ntp_update_offset(txc->offset);
>>                }
>>                if (txc->modes & ADJ_TICK)
>>                        tick_usec = txc->tick;
>>
>> -               if (txc->modes & (ADJ_TICK|ADJ_FREQUENCY|ADJ_OFFSET))
>> +               if ((txc->modes & (ADJ_TICK|ADJ_FREQUENCY|ADJ_OFFSET)) &&
>> +                               (txc->modes != ADJ_OFFSET_SS_READ))
>>                        ntp_update_frequency();
>>        }
>>
>>
>>
>>
>
>
>
> --
> Michael Kerrisk
> Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
> man-pages online: http://www.kernel.org/doc/man-pages/online_pages.html
> Found a bug? http://www.kernel.org/doc/man-pages/reporting_bugs.html
>



-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
man-pages online: http://www.kernel.org/doc/man-pages/online_pages.html
Found a bug? http://www.kernel.org/doc/man-pages/reporting_bugs.html

  reply	other threads:[~2008-07-21 10:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-22  7:32 Michael Kerrisk
2008-06-30 22:07 ` john stultz
2008-07-01  1:30   ` Michael Kerrisk
2008-07-21 10:36     ` Michael Kerrisk [this message]
2008-07-21 19:59       ` Roman Zippel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cfd18e0f0807210336q3fa1102cq46708449af86a428@mail.gmail.com \
    --to=mtk.manpages@googlemail.com \
    --cc=johnstul@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mtk.manpages@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=zippel@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome