Page MenuHomePhabricator

Transform ProcessLauncherLinux to ProcessLauncherPosixFork
ClosedPublic

Authored by krytarowski on Jan 31 2017, 1:30 PM.

Details

Summary

Use ProcessLauncherPosixFork in Linux and NetBSD.

Changes to ProcessLauncherLinux:

  • Limit personality.h and ASLR code to Linux.
  • Reuse portable ptrace(2) PT_TRACE_ME operation available on Linux and BSDs.
  • Limit ETXTBSY error path from execve(2) to Linux.
  • In LaunchProcess declaration change virtual to override.

This code should be readily available for FreeBSD.

Sponsored by <The NetBSD Foundation>

Diff Detail

Repository
rL LLVM

Event Timeline

krytarowski created this revision.Jan 31 2017, 1:30 PM
labath requested changes to this revision.Jan 31 2017, 1:44 PM

This is also copying a lot of code only to make tiny changes to it. Please put the Linux process launcher into the posix folder (I suggest naming it ProcessLauncherPosixFork). Ifdef out the linux-specific parts (ASLR, personality) and you're done. :)

For bonus points, you can put the ASLR code into a separate function, and then ifdef-out only that - should make main code flow better.

This revision now requires changes to proceed.Jan 31 2017, 1:44 PM

This patch was already open in a discussion with @labath, I'm pushing it here to point the appropriate solution during review.

This is also copying a lot of code only to make tiny changes to it. Please put the Linux process launcher into the posix folder (I suggest naming it ProcessLauncherPosixFork). Ifdef out the linux-specific parts (ASLR, personality) and you're done. :)

For bonus points, you can put the ASLR code into a separate function, and then ifdef-out only that - should make main code flow better.

I will do it. Thank you for quick reply.

krytarowski edited edge metadata.

Transform ProcessLauncherLinux to ProcessLauncherPosixFork and attach to Linux and NetBSD.

krytarowski retitled this revision from Add ProcessLauncherNetBSD to spawn a tracee to Transform ProcessLauncherLinux to ProcessLauncherPosixFork.Jan 31 2017, 5:09 PM
krytarowski edited the summary of this revision. (Show Details)
labath accepted this revision.Jan 31 2017, 5:52 PM

Perfect. Thank you.

include/lldb/Host/posix/ProcessLauncherPosixFork.h
20

s/virtual/override/. (I know you just copied it, but still.. )

This revision is now accepted and ready to land.Jan 31 2017, 5:52 PM

@emaste: I'd suggest switching freebsd over to this process launcher as well. I think it's the last user of the ProcessLauncherPosix, and it would enable us to get rid of it.

virtual -> override

krytarowski edited the summary of this revision. (Show Details)Jan 31 2017, 6:18 PM
emaste edited edge metadata.Jan 31 2017, 7:08 PM

@emaste: I'd suggest switching freebsd over to this process launcher as well. I think it's the last user of the ProcessLauncherPosix, and it would enable us to get rid of it.

Indeed. I won't be able to look at it until next week, but will try to switch it over as soon as possible.

krytarowski closed this revision.Feb 1 2017, 6:41 AM