x25: defer socket cleanup on link termination to process context
Subsystems (3)
Hi Martin,
Thanks for the detailed test report - it settles the discussion. The stalled-owner case is what I had missed: the deferred worker blocks in lock_sock() until the owner releases the socket, so the window is as long as the send buffer takes to fault in, not microseconds. My "runs within microseconds" argument assumed nobody had the socket locked, and the workqueue approach is the wrong tool here.
Please drop this patch. I will not send another version of it, and I'll leave the fix to Thang's series.
The bh_lock_sock() pattern is clearly the better fit: clear immediately when the socket is not owned, otherwise set X25_KILL_FLAG and disconnect from release_cb, skip flagged sockets in __x25_find_socket() and in the transmit path, and keep a sleeping sweep for NETDEV_DOWN, where the device can be freed right after.
One thing that may be worth keeping in mind when you post it: in the October thread sashiko pointed out that x25_make_new() copies the parent's flags word (x25->flags = ox25->flags, af_x25.c:607) and only clears X25_INTERRUPT_FLAG. If X25_KILL_FLAG lives in that word, a child created while the parent is flagged inherits it, and the __x25_find_socket() skip and the transmit block would then apply to the child as well. The current posting may already handle this; I could not tell from the thread.
I have the syzbot repro for this report (extid 300375dfd44665f063a6) and a QEMU setup where it reproduces in under two minutes on current mainline. If a Tested-by from that setup would be useful when you post Thang's series, I'm happy to run it.
And noted, my mistake: new versions as a new thread with the version in the patch subject, not as a reply to the previous posting.
Thanks,
Shuai