mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Avoid panic opportunity for TCP keep-alive timers
There is a panic opportunity if the timer fires but the socket is going through cleanup. In this case `e.route` might go away but the timer handler for keep-alive continues to execute and causes panics. The fix is to return early from the handler if we find out the route is already removed. PiperOrigin-RevId: 619268432
This commit is contained in:
@@ -1292,6 +1292,11 @@ func (e *Endpoint) handleSegmentLocked(s *segment) (cont bool, err tcpip.Error)
|
||||
func (e *Endpoint) keepaliveTimerExpired() tcpip.Error {
|
||||
userTimeout := e.userTimeout
|
||||
|
||||
// If the route is not ready or already cleaned up, then we don't need to
|
||||
// send keepalives.
|
||||
if e.route == nil {
|
||||
return nil
|
||||
}
|
||||
e.keepalive.Lock()
|
||||
if !e.SocketOptions().GetKeepAlive() || e.keepalive.timer.isUninitialized() || !e.keepalive.timer.checkExpiration() {
|
||||
e.keepalive.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user