Re: [PATCH] prevent timespec/timeval to ktime_t overflow

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 };
 }
 


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux