Fix panic while setting TCP_CORK off.

TCP sender is initialized only in established state, check if sender is
available before disabling the TCP_CORK timer.

Reported-by: syzbot+653ff342d39edb34a49c@syzkaller.appspotmail.com
PiperOrigin-RevId: 616879762
This commit is contained in:
Nayana Bidari
2024-03-18 10:51:33 -07:00
committed by gVisor bot
parent 57dd80d5a8
commit 5f5e01d186
2 changed files with 12 additions and 1 deletions
+3 -1
View File
@@ -1763,7 +1763,9 @@ func (e *endpoint) OnCorkOptionSet(v bool) {
if !v {
e.LockUser()
defer e.UnlockUser()
e.snd.corkTimer.disable()
if e.snd != nil {
e.snd.corkTimer.disable()
}
// Handle the corked data.
if e.EndpointState().connected() {
e.sendData(nil /* next */)
+9
View File
@@ -2696,6 +2696,15 @@ TEST_P(SimpleTcpSocketTest, EpollListeningSocket) {
save_and_connect_thread.Join();
}
TEST_P(SimpleTcpSocketTest, SetTCPCorkOff) {
int fd;
ASSERT_THAT(fd = socket(GetParam(), SOCK_STREAM, IPPROTO_TCP),
SyscallSucceeds());
ASSERT_THAT(
setsockopt(fd, IPPROTO_TCP, TCP_CORK, &kSockOptOff, sizeof(kSockOptOff)),
SyscallSucceeds());
}
#endif // __linux__
INSTANTIATE_TEST_SUITE_P(AllInetTests, SimpleTcpSocketTest,