netdev
[Top] [All Lists]

Re: Patch: IPv6/AMD64: bug in net/ipv6/ndisc.c

To: kas@xxxxxxxxxxxxxxxxxxx
Subject: Re: Patch: IPv6/AMD64: bug in net/ipv6/ndisc.c
From: YOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@xxxxxxxxxxxxxx>
Date: Fri, 30 Jan 2004 08:37:43 +0900 (JST)
Cc: linux-kernel@xxxxxxxxxxxxxxx, netdev@xxxxxxxxxxx, yoshfuji@xxxxxxxxxxxxxx
In-reply-to: <20040129221538.J24747@fi.muni.cz>
Organization: USAGI Project
References: <20040129221538.J24747@fi.muni.cz>
Sender: netdev-bounce@xxxxxxxxxxx
In article <20040129221538.J24747@xxxxxxxxxx> (at Thu, 29 Jan 2004 22:15:38 
+0100), Jan Kasprzak <kas@xxxxxxxxxxxxxxxxxxx> says:

> while compiling the kernel (2.6.1) I have spotted the following warning:
> 
> net/ipv6/ndisc.c: In function `ndisc_router_discovery':
> net/ipv6/ndisc.c:1113: warning: comparison is always true due to limited 
> range of data type
:

> The corresponding lines are these:
> 
>                 __u32 rtime = ntohl(ra_msg->retrans_timer);
>                                                                               
>   
> Here --->       if (rtime && rtime/1000 < (MAX_SCHEDULE_TIMEOUT/HZ)) {
>                         rtime = (rtime*HZ)/1000;
>                         if (rtime < HZ/10)
>                                 rtime = HZ/10;
>                         in6_dev->nd_parms->retrans_time = rtime;
>                 }
:

> The MAX_SCHEDULE_TIMEOUT is #defined to LONG_MAX in include/linux/sched.h,
> which is 2^63-1 or so on AMD64. I propose the following fix:
:

+#define MAX_SCHEDULE_TIMEOUT_32 (MAX_SCHEDULE_TIMEOUT/HZ > (1U<<31) ? \
+       (1U<<31) : MAX_SCHEDULE_TIMEOUT/HZ)

Well,... ok for now.

For long term solution, I think it is better to store timing variables 
in "unsinged long" type instead of int. 
I think there's several places to be fixed.
We'll need proc_doulongvec_jiffies(), proc_doulongvec_userhz_jiffies().

--yoshfuji

<Prev in Thread] Current Thread [Next in Thread>