On Thursday, 21.06.2018 at 07:46, Adam Steen wrote:
> > > Mirage-Skeleton Hello World Tutorial, I now find this causes as "
> > > 
> > > mprotect W^X violation" on OpenBSD.
> > 
> > That's err, odd. Do you get a "Warning: phdr[N] requests WRITE and EXEC
> > 
> > permissions" when running ukvm-bin?
> 
> Yes.

Right, so your ELF is requesting such a segment, in which case the failure
is expected (without manually disabling W^X for the ukvm-bin).

> > When you write "causes a mprotect W^X violation", how does that actually
> > 
> > manifest itself at run-time? Does ukvm-bin get killed? Or some other way?
> 
> ukvm-bin gets killed by the kernel.
> 
> "ukvm-bin: hello.ukvm: Warning: phdr[0] requests WRITE and EXEC permissions"
> "ukvm-bin: hello.ukbm: Not Supported"

The second error would be from the mprotect() returning ENOTSUP, which is
due to the W^X policy, and ukvm-bin is correctly aborting in that case.

> Looks like I will have to dig a little deeper, I do recall something like 
> this happening soon after i got things working on a custom kernel. I am awol 
> again next week, but will try to nail down exactly what caused the issue.
> 
> Thanks for the confirmation about linux and a starting point with "readelf -l"

As I wrote initially, this looks like something in the MirageOS build on
OpenBSD is generating a segment with W & X on it. You can double-confirm by
e.g. building the same unikernel on Linux and seeing if it runs on OpenBSD.

If it changed recently then it's possible that either a) you were
previously running a kernel that did not enforce this or b) the build
toolchain changed and/or due to a) you did not notice that it's producing W
& X segments in the first place.

I'd ask around on the OpenBSD lists and/or check the various clang / ld
manual pages for any options that might affect this.

-mato

Reply via email to