vtty
vtty copied to clipboard
closing the port at the wrong moment causes a kernel oops
I don't recall the exact circumstances, this is just a note to myself to test and fix this one day
I can reproduce at least some kernel oops, so I plan to come up with some investigation and perhaps a solution. My starting point is your little test program, where the error is already reproducible.
I like your little driver, a neat piece of code. I want to use it as the kernel side base for some larger project, where I implement a RFC2217 client compatible virtual TTY provider.
After cranking up the debug output, so I could figure out, where my kernel OOPS came from.
i tested against 5.15.41-gentoo
and used your little neat test program.
The problem I identified was a kind of race or actually the close order of master and slave side of a port.
A possible solution is in https://github.com/joluxer/vtty/commit/f43c2f8b1085804b9d0f69172c22cef5f324e465
My way to go was serializing the destruction of the port data and delaying it, until both ends of the vtty are closed and the tty structures are cleaned up by the kernel. This required to keep the port data not zeroed, until the next time the port gets created.