can-utils icon indicating copy to clipboard operation
can-utils copied to clipboard

Reading from a non-bound Raw CAN socket blocks indefinitely

Open derek-will opened this issue 3 years ago • 1 comments

This is quite similar to the situation found earlier for ISO-TP sockets. If there is an attempt to read from an unbound socket, then the call will be blocked indefinitely because of course there will not be any messages received when the socket is not bound to an interface.

My suggestion is that we return an error when a read, recv, etc. is attempted on an unbound socket as it is certainly an error on the application programmer's part.

Somewhere in raw_recvmsg we could add a "is socket bound" check: https://elixir.bootlin.com/linux/latest/source/net/can/raw.c#L843

derek-will avatar Apr 18 '22 18:04 derek-will

Yes. Makes sense for CAN_RAW and for the 'unconnected/unbound' CAN_BCM socket too. At least better than "Learning by pain" (here: loss of lifetime) :-D

Will add Reported-by/Suggested-by tags for you. Thx!

hartkopp avatar Apr 18 '22 18:04 hartkopp