Page MenuHomeFreeBSD

Hold an explicit reference on the socket for the aiotx task.
ClosedPublic

Authored by jhb on Jun 6 2019, 6:47 PM.

Details

Summary

Previously, the aiotx task relied on the aio jobs in the queue to hold
a reference on the socket. However, when the last job is completed,
there is nothing left to hold a reference to the socket buffer lock used
to check if the queue is empty. In addition, if the last job on the queue
is cancelled, the task can run with no queued jobs holding a reference
to the socket buffer lock the task uses to notice the queue is empty.

Fix these races by holding an explicit reference on the socket when the
task is queued and dropping that reference when the task completes.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

jhb created this revision.Jun 6 2019, 6:47 PM
jhb added a comment.Jun 6 2019, 6:50 PM

So while writing the log message, I decided I still don't really like this version. Namely, even after dequeueing the last job, we will then try to lock the socket buffer to check the queue, if we completed the last job we might have dropped the last reference to the socket and freed it. So I think the real fix is we have to grab a reference when queueing the task. I don't know if a reference on the socket is enough to keep inp->inp_socket itself stable though?

jhb updated this revision to Diff 58324.Jun 6 2019, 7:03 PM

Make the aiotx task hold an explicit reference on the socket.

jhb retitled this revision from Ensure any pending task has stopped when cancelling the last aiotx job. to Hold an explicit reference on the socket for the aiotx task..Jun 6 2019, 7:11 PM
jhb edited the summary of this revision. (Show Details)
np accepted this revision.Jun 27 2019, 7:16 PM

I ran the same aio tx test that used to panic the system and verified that this change fixes the problem.

This revision is now accepted and ready to land.Jun 27 2019, 7:16 PM
This revision was automatically updated to reflect the committed changes.