Trying to use socketpair for lldb-server fails

To avoid a local privilage escalation, I am trying to patch LLDB not to
use a TCP socket for local communication.

The attached patch failed. Would anyone be able to provide suggestions
for how to debug the problem?

Sincerely,

Demi

output.patch (3.43 KB)

The first thing I'd do is use the lldb logging mechanism. lldb-server closes
its own stdout and stderr, because nobody is interested in output from the
server, just from the target. Except when you're debugging the server, so
there is an easy way to turn on logging.

Set the following environment variables:
LLDB_DEBUGSERVER_LOG_FILE - this contains the path to the file the logs will
be written to
LLDB_SERVER_LOG_CHANNELS - this contains the channels and categories to turn
logging on for. The format is "channel category:channel category...". If you
want more than 1 category for a channel, I think "channel cat1 cat2..."
works. This is not spelled out very clearly, unfortunately.

Quickly glancing at the code, it looks like you need to implement a
socketpair connection, and handling of the fd:// connection URL, starting in
ConnectionFileDescriptor::Connect. The log for this would be "lldb
connection".

Ted

Sadly, that gives me nothing in the log file. Also, ConnectionFileDescriptor::Connect already seems to handle this case.

Running strace on all child processes gives a “Operation not permitted” error from setsid(). That seems like the culprit, which is strange.

Would you mind providing the value you used for LLDB_SERVER_LOG_CHANNELS?

Demi

This is big time overkill, but I wasn’t sure where the problem I was tracking down was:

“lldb all:linux all:gdb-remote all”

Ted