tech-net archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Preloading libraries to override BSD IPC function symbols and recursion
Lately while doing a test, I noticed that if a library overrides
socket(2) and attempts to call the original socket(2) function from
libc, a recursive loop fills the stack causing a segmentation fault in
wrapped applications using socket(2).
I then remembered that some wrappers such as tsocks and proxychains
also occasionally crashed with some programs. Tsocks doesn't seem to
override socket(2) but it overrides select(2) and connect(2). Some
applications work fine, others crash with select()/__select50() calling
eachother recursively.
Using nm(1) on /usr/pkg/lib/libtsocks.so:
000000000000226b T connect
0000000000207480 b realconnect
0000000000002751 T __select50
0000000000207478 b realselect
Using nm(1) on test /usr/local/lib/nonet-unix.so:
0000000000000953 T __socket30
0000000000200f70 b real_socket
If in my nonet test I dlsym(3) "__socket30" instead of "socket", it
works fine. Which begs the question: how are those programs expected
to know which symbol to use (they expect the standard symbol name).
Some tricks can be used to discover it, of course.
But is there a better solution to always get this right?
Thanks,
--
Matt
Home |
Main Index |
Thread Index |
Old Index