[zeromq-dev] Protection against altering ZMQ internal socketpairs

Martin Sustrik sustrik at 250bpm.com
Thu Feb 24 10:38:03 CET 2011


Hi Andrew,

> My proposal is to check for EBADF somewhere in zmq::mailbox_t::recv and
> print out a nice message like "Internal socketpair closed, maybe you
> tried closing a ZMQ FD? Please don't do that"

Yes. Can be done.

The nasty part is that a closed FD can be immediately reused by the OS 
in which case the mailbox would subsequently read/write from a wrong 
socket :|

Another ugly problem is that the aside of closing the fd, user 
application can read or write to the fd which is undetectable and would 
mess with 0mq's internal logic badly.

In short, it looks like the only real solution to the problem is placing 
a big warning to the documentation saying "NEVER USE THIS FILE 
DESCRIPTOR FOR ANYTHING OTHER THAN POLLING FOR INCOMING DATA".

Thoughts?
Martin



More information about the zeromq-dev mailing list