Skip to content

Commit

Permalink
strparser: Do not call mod_delayed_work with a timeout of LONG_MAX
Browse files Browse the repository at this point in the history
struct sock's sk_rcvtimeo is initialized to
LONG_MAX/MAX_SCHEDULE_TIMEOUT in sock_init_data. Calling
mod_delayed_work with a timeout of LONG_MAX causes spurious execution of
the work function. timer->expires is set equal to jiffies + LONG_MAX.
When timer_base->clk falls behind the current value of jiffies,
the delta between timer_base->clk and jiffies + LONG_MAX causes the
expiration to be in the past. Returning early from strp_start_timer if
timeo == LONG_MAX solves this problem.

Found while testing net/tls_sw recv path.

Fixes: 43a0c67 ("strparser: Stream parser for messages")
Reviewed-by: Tejun Heo <[email protected]>
Signed-off-by: Doron Roberts-Kedes <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Doron Roberts-Kedes authored and davem330 committed Apr 23, 2018
1 parent a957fa1 commit 7c5aba2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/strparser/strparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static void strp_abort_strp(struct strparser *strp, int err)

static void strp_start_timer(struct strparser *strp, long timeo)
{
if (timeo)
if (timeo && timeo != LONG_MAX)
mod_delayed_work(strp_wq, &strp->msg_timer_work, timeo);
}

Expand Down

0 comments on commit 7c5aba2

Please sign in to comment.