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
Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp =================================================================== --- source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (revision 308480) +++ source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (working copy) @@ -3289,7 +3289,8 @@ } return error; } -#if defined(__APPLE__) +#ifndef _WIN32 +//#ifdef __APPLE__ #define USE_SOCKETPAIR_FOR_LOCAL_CONNECTION 1 #endif Index: tools/lldb-server/lldb-gdbserver.cpp =================================================================== --- tools/lldb-server/lldb-gdbserver.cpp (revision 308480) +++ tools/lldb-server/lldb-gdbserver.cpp (working copy) @@ -97,6 +97,7 @@ {"attach", required_argument, NULL, 'a'}, {"named-pipe", required_argument, NULL, 'N'}, {"pipe", required_argument, NULL, 'U'}, + {"fd", required_argument, NULL, 'F'}, {"native-regs", no_argument, NULL, 'r'}, // Specify to use the native registers instead of the gdb defaults // for the architecture. NOTE: this is a do-nothing arg as it's @@ -232,7 +233,8 @@ GDBRemoteCommunicationServerLLGS &gdb_server, bool reverse_connect, const char *const host_and_port, const char *const progname, const char *const subcommand, - const char *const named_pipe_path, int unnamed_pipe_fd) { + const char *const named_pipe_path, int unnamed_pipe_fd, + int connection_fd) { Status error; if (host_and_port && host_and_port[0]) { @@ -257,7 +259,24 @@ std::unique_ptr<Connection> connection_up; - if (reverse_connect) { + if (connection_fd != -1) { + abort(); + char connection_url[512]; + snprintf(connection_url, sizeof(connection_url), "fd://%d", connection_fd); + connection_up.reset(new ConnectionFileDescriptor); + auto connection_result = connection_up->Connect(connection_url, &error); + if (connection_result != eConnectionStatusSuccess) { + fprintf(stderr, "error: failed to connect to client at '%s' " + "(connection status: %d)", + connection_url, static_cast<int>(connection_result)); + exit(-1); + } + if (error.Fail()) { + fprintf(stderr, "error: failed to connect to client at '%s': %s", + connection_url, error.AsCString()); + exit(-1); + } + } else if (reverse_connect) { // llgs will connect to the gdb-remote client. // Ensure we have a port number for the connection. @@ -364,6 +383,7 @@ log_channels; // e.g. "lldb process threads:gdb-remote default:linux all" int unnamed_pipe_fd = -1; bool reverse_connect = false; + int connection_fd = -1; // ProcessLaunchInfo launch_info; ProcessAttachInfo attach_info; @@ -413,6 +433,11 @@ reverse_connect = true; break; + case 'F': + if (optarg && optarg[0]) + connection_fd = StringConvert::ToUInt32(optarg, -1); + break; + #ifndef _WIN32 case 'S': // Put llgs into a new session. Terminals group processes @@ -501,7 +526,7 @@ ConnectToRemote(mainloop, gdb_server, reverse_connect, host_and_port, progname, subcommand, named_pipe_path.c_str(), - unnamed_pipe_fd); + unnamed_pipe_fd, connection_fd); if (!gdb_server.IsConnected()) { fprintf(stderr, "no connection information provided, unable to run\n");
_______________________________________________ lldb-dev mailing list lldb-dev@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev