From: John Stultz <johnstul@us.ibm.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] Enforce valid shift values in clocksource_register()
Date: Wed, 26 Nov 2008 16:39:18 -0800 [thread overview]
Message-ID: <1227746358.18967.41.camel@jstultz-laptop> (raw)
In-Reply-To: <alpine.LFD.2.00.0811270105270.3325@localhost.localdomain>
On Thu, 2008-11-27 at 01:08 +0100, Thomas Gleixner wrote:
> On Wed, 26 Nov 2008, John Stultz wrote:
>
> > Thomas noted that some of the timekeeping core assumes
> > clocksource shift values will be less then 32. However,
> > we do nothing to enforce such limits.
> >
> > This patch prints a warning if a clocksource with an invalid
> > shift value is attempted to be registered, and will refuse to
> > register the clocksource
> >
> > I could not find any clocksources that use 32 or higher for a
> > shift value, so this should be only a preventive warning for
> > future clocksource writers.
> >
> > Signed-off-by: John Stultz <johnstul@us.ibm.com>
> >
> > diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
> > index 9ed2eec..4a3bb13 100644
> > --- a/kernel/time/clocksource.c
> > +++ b/kernel/time/clocksource.c
> > @@ -318,7 +318,7 @@ static int clocksource_enqueue(struct clocksource *c)
> > * clocksource_register - Used to install new clocksources
> > * @t: clocksource to be registered
> > *
> > - * Returns -EBUSY if registration fails, zero otherwise.
> > + * Returns -EBUSY or -EINVAL if registration fails, zero otherwise.
> > */
> > int clocksource_register(struct clocksource *c)
> > {
> > @@ -327,7 +327,14 @@ int clocksource_register(struct clocksource *c)
> >
> > /* save mult_orig on registration */
> > c->mult_orig = c->mult;
> > -
> > + if (c->shift >= 32) {
> > + printk(KERN_WARNING "===============================\n");
> > + printk(KERN_WARNING "WARNING: Cannot register %s clocksource\n",
> > + c->name);
> > + printk(KERN_WARNING "The shift value must be less then 32\n");
> > + printk(KERN_WARNING "===============================\n");
> > + return -EINVAL;
>
> Just setting the shift value to 31 along with a WARN_ON() should be
> enough. We don't need to kill the clocksource in that case, as this
> can be nasty when it happens in the early boot code where we dont have
> any output.
Well, we can't tweak the shift value without changing the mult. And that
seemed a bit overreaching (but might be safe). I'll give it a shot.
Also early boot we should have the jiffies clocksource around, so unless
I'm forgetting something, I don't think it has early boot concerns.
thanks
-john
next prev parent reply other threads:[~2008-11-27 0:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-26 23:46 John Stultz
2008-11-27 0:08 ` Thomas Gleixner
2008-11-27 0:39 ` John Stultz [this message]
2008-11-27 0:54 ` Thomas Gleixner
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=1227746358.18967.41.camel@jstultz-laptop \
--to=johnstul@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/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
all inboxes | Powered by JetHome®