You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On real Linux, ptrace(PTRACE_OLDSETOPTIONS, 2831, NULL, 0x1) works properly, but it returns EINVAL (Invalid argument) on WSL. This syscall is called in the "Checking that ptrace can change system call numbers..." routine of UML.
Looks like we do not have this ptrace implemented. Could you please provide a little bit more detail on the application that is using this option so we can prioritize the implementation?
Ben Hillis (@benhillis) the application is the User-Mode Linux kernel itself :)
It's an official implementation of the Linux kernel that runs fully in user-mode, with modules and everything.
Ben Hillis (@benhillis) - PTRACE_OLDSETOPTIONS (value 21 decimal) behaves the same as PTRACE_SETOPTIONS (value 0x4200). They changed the value of the constant (for reasons) over a decade ago, but the semantics did not change. That is, the other three ptrace() parameters are treated exactly the same, whether the first parameter is 21 or 0x4200. The values are literally aliases. So you can fix this in five minutes if you feel inclined. Might as well, because it is that easy. No strings, honest. You do not need to emulate any 'old' behavior. From man7.org:
On hosts with 2.6 kernel headers, PTRACE_SETOPTIONS is declared with a different value than the one for 2.4. This leads to applications compiled with 2.6 kernel headers failing when run on 2.4 kernels. This can be worked around by redefining PTRACE_SETOPTIONS to PTRACE_OLDSETOPTIONS, if that is defined.
Also, for a little context, the only software I can find on the planet that cares is User Mode Linux. Unless someone tries to run some statically linked strace or maybe gdb binary from the 2.4 era, this will simply never be hit on WSL in 2017. UML seems to still care, entirely academically, to maintain binary compatibility with 2.4. You can think of it as UML never buying into the idea the value changed, while everyone else moved on.
UML won't run on WSL right now anyway, because it will brick wall on #688, and who knows what else. But the issue as presented can be addressed.
Repro steps for the pedantry of it.
wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.10.tar.xz
tar xf linux-4.10.tar.xz
cd linux-4.10
make defconfig ARCH=um
make -j8 ARCH=um
./linux
I've fixed this but the change is unlikely to make the Creators Update release because User-Mode Linux is blocked by other things and as therealkenc noticed the usage of this is exceedingly rare.
PTRACE_TRACEME is #688, as cited twice above. This issue is PTRACE_OLDSETOPTIONS, which was addressed successfully if you are now hitting PTRACE_TRACEME.
"Invalid argument" and "operation not permitted" are different errors though? I get the PTRACE_TRACEME when strace'ing, but I'm not sure what's happening when I don't strace, and whether that's still the "invalid argument" that woachk got originally.
How do I figure out what's going on, and why I get different errors with and without strace?
UML maintainer here.
Strictly speaking, to run UML you don't need PTRACE_OLDSETOPTIONS nor the ability to change syscall numbers via ptrace(). UML checks for these features because Linux supports them since ever and UML can fallback to them.
What you really need is PTRACE_SYSEMU.
That's the ptrace() side, what worries me more is that a quick test on WSL showed that SIGSEGV has no valid machine specific signal context. At least the CR2 register is 0x0 and does not expose the faulting address. This makes it impossible for UML to handle page faults in userspace.
The (very narrow) request for PTRACE_OLDSETOPTIONS in the OP has been dangling in a fixinbound state since early 2017. #2555 can serve as a surrogate for the "SIGSEGV has no valid machine specific signal context" issue. PTRACE_SYSEMU would be really nice, but that should be filed under its own cover. People can take another run at UML on WSL (in general) after those two blockers (at least) are addressed.
Activity
[-]Ptrace difference in behaviour[/-][+]PTRACE_OLDSETOPTIONS incompatible behaviour[/+]benhillis commentedon Feb 15, 2017
Looks like we do not have this ptrace implemented. Could you please provide a little bit more detail on the application that is using this option so we can prioritize the implementation?
woachk commentedon Feb 15, 2017
Ben Hillis (@benhillis) the application is the User-Mode Linux kernel itself :)
It's an official implementation of the Linux kernel that runs fully in user-mode, with modules and everything.
therealkenc commentedon Feb 21, 2017
Ben Hillis (@benhillis) - PTRACE_OLDSETOPTIONS (value 21 decimal) behaves the same as PTRACE_SETOPTIONS (value 0x4200). They changed the value of the constant (for reasons) over a decade ago, but the semantics did not change. That is, the other three
ptrace()parameters are treated exactly the same, whether the first parameter is 21 or 0x4200. The values are literally aliases. So you can fix this in five minutes if you feel inclined. Might as well, because it is that easy. No strings, honest. You do not need to emulate any 'old' behavior. From man7.org:Also, for a little context, the only software I can find on the planet that cares is User Mode Linux. Unless someone tries to run some statically linked
straceor maybegdbbinary from the 2.4 era, this will simply never be hit on WSL in 2017. UML seems to still care, entirely academically, to maintain binary compatibility with 2.4. You can think of it as UML never buying into the idea the value changed, while everyone else moved on.UML won't run on WSL right now anyway, because it will brick wall on #688, and who knows what else. But the issue as presented can be addressed.
Repro steps for the pedantry of it.
benhillis commentedon Feb 21, 2017
I've fixed this but the change is unlikely to make the Creators Update release because User-Mode Linux is blocked by other things and as therealkenc noticed the usage of this is exceedingly rare.
woachk commentedon Feb 21, 2017
Ben Hillis (@benhillis) thanks anyway ;)
I hope that it'll start to work somewhere in the future
daiconrad commentedon Apr 8, 2017
This is apparently also needed to run the Swift REPL under WSL: #688
thorsteneb commentedon Apr 22, 2017
Ben Hillis (@benhillis) I see "Add support for PTRACE_OLDSETOPTIONS. [GH 1692]" in build 16170. I'm in 16179. I don't think it's fixed yet.
When I follow therealkenc 's reproduction steps and run
./linux, I get:When I try to strace that behavior, I get a different error:
The strace file contains this:
therealkenc commentedon Apr 22, 2017
PTRACE_TRACEMEis #688, as cited twice above. This issue isPTRACE_OLDSETOPTIONS, which was addressed successfully if you are now hittingPTRACE_TRACEME.thorsteneb commentedon Apr 23, 2017
"Invalid argument" and "operation not permitted" are different errors though? I get the PTRACE_TRACEME when strace'ing, but I'm not sure what's happening when I don't strace, and whether that's still the "invalid argument" that woachk got originally.
How do I figure out what's going on, and why I get different errors with and without strace?
therealkenc commentedon Apr 23, 2017
Based on the error to stdout you reported, it looks like UML is also hitting
PTRACE_POKEUSERhere:So: "Yeah, that too"
richardweinberger commentedon May 11, 2017
UML maintainer here.
Strictly speaking, to run UML you don't need PTRACE_OLDSETOPTIONS nor the ability to change syscall numbers via ptrace(). UML checks for these features because Linux supports them since ever and UML can fallback to them.
What you really need is PTRACE_SYSEMU.
That's the ptrace() side, what worries me more is that a quick test on WSL showed that SIGSEGV has no valid machine specific signal context. At least the CR2 register is 0x0 and does not expose the faulting address. This makes it impossible for UML to handle page faults in userspace.
i.e.
The expected output is:
Please let me know if there is something I can do or explain. UML is rather old and uses not so well known Linux features. :-)
therealkenc commentedon Mar 26, 2018
The (very narrow) request for
PTRACE_OLDSETOPTIONSin the OP has been dangling in a fixinbound state since early 2017. #2555 can serve as a surrogate for the "SIGSEGV has no valid machine specific signal context" issue.PTRACE_SYSEMUwould be really nice, but that should be filed under its own cover. People can take another run at UML on WSL (in general) after those two blockers (at least) are addressed.