strparser: Do not call mod_delayed_work with a timeout of LONG_MAX
Subsystems (2)
PATCH 1/1 strparser: Do not call mod_delayed_work with a timeout of LONG_MAX
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.
--- net/strparser/strparser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/strparser/strparser.c +1 -1
@@ -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); }
Signature · 1 line
2.9.5
David Miller
maintainerFrom: Doron Roberts-Kedes <[email protected]>
Date: Fri, 20 Apr 2018 12:11:11 -0700
Quoted 9 lines
struct sock's
sk_rcvtimeois initialized to LONG_MAX/MAX_SCHEDULE_TIMEOUT insock_init_data. Callingmod_delayed_workwith a timeout ofLONG_MAXcauses spurious execution of the work function.timer->expiresis set equal to jiffies +LONG_MAX. Whentimer_base->clkfalls behind the current value of jiffies, the delta betweentimer_base->clkand jiffies +LONG_MAXcauses the expiration to be in the past. Returning early fromstrp_start_timerif timeo ==LONG_MAXsolves this problem.
Quoted 5 lines
Found while testing
net/tls_swrecv path.Fixes 43a0c6751a322847 ("strparser: Stream parser for messages")Reviewed-by Tejun Heo <[email protected]>Signed-off-by Doron Roberts-Kedes <[email protected]>
Applied and queued up for -stable, thanks.