netstack: Use ctx.BlockWithTimeout() directly while releasing socket.
When ctx is of type `kernel.taskAsyncContext`, calling `kernel.TaskFromContext(ctx)` on it returns the original task (even though this is an async goroutine). And then calling methods like Block() on it would panic because it expects to be running on the task goroutine. Furthermore, the Task could have exited so working on a dead task could cause other issues too. Instead, use `kernel.taskAsyncContext` methods via the context.Context interface. This change adds BlockWithTimeout() to the context interface and implements it for context.NoTask. kernel.Task already implements this. The current implementation of context.NoTask.BlockWithTimeoutOn was buggy: - It returned true when the desired event occurred OR when the timeout expired. However, context.Blocker interface docstring suggest that true should only be returned when the desired event occurs, which kernel.Task implements correctly. - Instead of returning the remaining timeout, it returned the duration passed since the timer started. Fixed these two bugs and made the implementations of kernel.Task and context.NoTask consistent with one another. Also clarified docstrings for some Task.Block*() methods about the precondition of "The caller must be running on the task goroutine.". Reported-by: syzbot+ef8ca995c8007b155130@syzkaller.appspotmail.com Reported-by: syzbot+cd7674e26d610c022ec9@syzkaller.appspotmail.com PiperOrigin-RevId: 853557307
A
Ayush Ranjan committed
2f5377660b6f9f21c2c37bebf202710d77bc4b4b
Parent: a1eb5ff
Committed by gVisor bot <gvisor-bot@google.com>
on 1/8/2026, 6:17:38 AM