mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Andrew Morton <akpm@osdl.org>
Cc: Ingo Molnar <mingo@elte.hu>, LKML <linux-kernel@vger.kernel.org>,
	Frank v Waveren <fvw@var.cx>
Subject: Re: [PATCH] prevent timespec/timeval to ktime_t overflow
Date: Fri, 01 Sep 2006 10:56:19 +0200	[thread overview]
Message-ID: <1157100979.29250.319.camel@localhost.localdomain> (raw)
In-Reply-To: <20060831204612.73ed7f33.akpm@osdl.org>

On Thu, 2006-08-31 at 20:46 -0700, Andrew Morton wrote:
> >   * ktime_t definitions when using the 64-bit scalar representation:
> > @@ -73,6 +74,10 @@ typedef union {
> >   */
> >  static inline ktime_t ktime_set(const long secs, const unsigned long nsecs)
> >  {
> > +#if (BITS_PER_LONG == 64)
> > +	if (unlikely(secs >= KTIME_SEC_MAX))
> > +		return (ktime_t){ .tv64 = KTIME_MAX };
> > +#endif
> >  	return (ktime_t) { .tv64 = (s64)secs * NSEC_PER_SEC + (s64)nsecs };
> >  }
> >  
> 
> This makes my FC3 x86_64 testbox hang during udev startup.  sysrq-T trace at
> http://www.zip.com.au/~akpm/linux/patches/stuff/log-x.

Does not help much.

> I had a quick look at the args to hrtimer_nanosleep and all seems to be in
> order.

Hmm. I can not reproduce that on any one of my boxen. Can you please try
with this debug variant, so we have a chance to figure out what's wrong.

	tglx

Index: linux-2.6.18-rc5/include/linux/ktime.h
===================================================================
--- linux-2.6.18-rc5.orig/include/linux/ktime.h	2006-08-31 18:58:32.000000000 +0200
+++ linux-2.6.18-rc5/include/linux/ktime.h	2006-09-01 10:47:59.000000000 +0200
@@ -57,6 +57,7 @@ typedef union {
 } ktime_t;
 
 #define KTIME_MAX			(~((u64)1 << 63))
+#define KTIME_SEC_MAX			(KTIME_MAX / NSEC_PER_SEC)
 
 /*
  * ktime_t definitions when using the 64-bit scalar representation:
@@ -73,6 +74,13 @@ typedef union {
  */
 static inline ktime_t ktime_set(const long secs, const unsigned long nsecs)
 {
+#if (BITS_PER_LONG == 64)
+	if (unlikely(secs >= KTIME_SEC_MAX)) {
+		printk("ktime_set: %ld : %lu\n", secs, nsecs);
+		WARN_ON(1);
+		return (ktime_t){ .tv64 = KTIME_MAX };
+	}
+#endif
 	return (ktime_t) { .tv64 = (s64)secs * NSEC_PER_SEC + (s64)nsecs };
 }
 



  reply	other threads:[~2006-09-01  8:52 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-30  8:44 Thomas Gleixner
2006-08-30 21:44 ` Frank v Waveren
2006-08-30 22:05   ` Thomas Gleixner
2006-08-30 22:08     ` Frank v Waveren
2006-08-30 22:22       ` Thomas Gleixner
2006-08-30 22:26         ` Frank v Waveren
2006-09-01  3:46 ` Andrew Morton
2006-09-01  8:56   ` Thomas Gleixner [this message]
2006-09-01  9:04     ` Andrew Morton
2006-09-01  9:30       ` Thomas Gleixner
2006-09-02  3:13         ` Andrew Morton
2006-09-02  3:32           ` Andrew Morton
2006-09-02  8:08           ` Andi Kleen
2006-09-02 18:41           ` Thomas Gleixner
2006-09-02 19:28             ` Thomas Gleixner
2006-09-02 19:43               ` Andrew Morton
2006-09-02 19:32             ` Andrew Morton
2006-09-02 11:04   ` Frank v Waveren
2006-09-02 18:44     ` Thomas Gleixner
2006-09-03  3:13       ` Frank v Waveren

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=1157100979.29250.319.camel@localhost.localdomain \
    --to=tglx@linutronix.de \
    --cc=akpm@osdl.org \
    --cc=fvw@var.cx \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /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