On Sun, Aug 8, 2010 at 18:45, Shawn Bohrer wrote: > @@ -1116,18 +1113,22 @@ static int ep_send_events(struct eventpoll *ep, > Âstatic int ep_poll(struct eventpoll *ep, struct epoll_event __user *events, >          int maxevents, long timeout) > Â{ > -    int res, eavail; > +    int res, eavail, timed_out = 0; >    Âunsigned long flags; > -    long jtimeout; > +    long slack; >    Âwait_queue_t wait; > - > -    /* > -    Â* Calculate the timeout by checking for the "infinite" value (-1) > -    Â* and the overflow condition. The passed timeout is in milliseconds, > -    Â* that why (t * HZ) / 1000. > -    Â*/ > -    jtimeout = (timeout < 0 || timeout >= EP_MAX_MSTIMEO) ? > -        MAX_SCHEDULE_TIMEOUT : (timeout * HZ + 999) / 1000; > +    struct timespec end_time; > +    ktime_t expires, *to = NULL; > + > +    if (timeout > 0) { > +        ktime_get_ts(&end_time); > +        timespec_add_ns(&end_time, (u64)timeout * NSEC_PER_MSEC); > +        slack = estimate_accuracy(&end_time); > +        to = &expires; > +        *to = timespec_to_ktime(end_time); > +    } else if (timeout == 0) { > +        timed_out = 1; > +    } > > Âretry: >    Âspin_lock_irqsave(&ep->lock, flags); > @@ -1149,7 +1150,7 @@ retry: >             * to TASK_INTERRUPTIBLE before doing the checks. >             */ >            Âset_current_state(TASK_INTERRUPTIBLE); > -            if (!list_empty(&ep->rdllist) || !jtimeout) > +            if (!list_empty(&ep->rdllist) || timed_out) >                Âbreak; >            Âif (signal_pending(current)) { >                Âres = -EINTR; > @@ -1157,7 +1158,9 @@ retry: >            Â} > >            Âspin_unlock_irqrestore(&ep->lock, flags); > -            jtimeout = schedule_timeout(jtimeout); > +            if (!schedule_hrtimeout_range(to, slack, HRTIMER_MODE_ABS)) > +                timed_out = 1; > + >            Âspin_lock_irqsave(&ep->lock, flags); >        Â} >        Â__remove_wait_queue(&ep->wq, &wait); this code introduces a warning: fs/eventpoll.c: In function âep_pollâ: fs/eventpoll.c:1119: warning: âslackâ may be used uninitialized in this function looks to me like you arent properly handling negative timeouts. certainly epoll_wait() passes the timeout value straight from userspace to ep_poll() without any error checking, so if userspace passes a negative timeout value, it looks like "slack" will be used uninitialized. -mike ÿô.nÇ·®+%˱é¥wÿº{.nÇ·¥{±ýþ)íèjg¬±¨¶Ýjÿ¾«þG«é¸¢·¦j:+v¨wèm¶ÿþø®w¥þ࣢·hâÿÙ