NetBSD-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Wine11 and PaX MPROTECT
> `sysctl -w security.pax.mprotect.debug=1'
Neat. Thank you. Unfortunately the process was wine and it does have +m.
After investigating it a bit more I found this in `man mmap`
> As a NetBSD extension, the PROT_MPROTECT macro can be used to request
> additional permissions for later use with mprotect(2). For example
> PROT_MPROTECT(PROT_READ) requests that future PROT_READ mappings are
> allowed and can be enabled using mprotect(2), but does not currently
> grant read mappings to the returned memory segment. This is necessary
> for switching pages between writable and executable when PaX MPROTECT
> restrictions are in place. See mremap(2) for a sample use case.
I'm 99% convinced that this is the issue. My interpretation of it is
that mmap on NetBSD must be called with the PROT_MPROTECT macro if we
decide to call mprotect() later with some permissions changed.
In case of Wine, when it parses PE exe sections, it calls mmap on them
with PROT_READ | PROT_WRITE and then it goes through those sections
again and tries to mark the .text section (at least) as PROT_EXEC. I'm
sure it works on other systems but NetBSD needs that
PROT_MPROTECT(PROT_EXEC) in the relatd mmap call if we want to mark
this section as executable.
I was able to make the mprotect related segfault go away, but
unfortunately it now segfault for other reasons. I'm sure I messed up
with all these mmap and mprotect calls, so I'm gonna experiment more.
Probably I should run ktruss on it again to see what's happening.
Thanks a lot for your input, guys.
Ruslan
On Tue, Nov 24, 2026 at 9:05 PM RVP <rvp%sdf.org@localhost> wrote:
>
> On Sun, 22 Nov 2026, Ruslan Bekenev wrote:
>
> > I spent some time trying to port Wine 11 (recent one) to NetBSD (I'm
> > on 11.0 atm).
> > It was mostly just migration of patches from existing emulators/wine.
> > It works fine and I was able to run some windows CLI programs and just
> > have run TotalCommander (gui file manager).
> >
> > My current problem is that any time I call wine <program> I get
> > segfault due to MPROTECT. The wine binary has paxctl +m set which as
> > far as I understand should disable the protection. Unfortunately it
> > still crashes. It works fine though, if I disable mprotect completely
> > with sysctl -w security.pax.mprotect.global=0.
> >
>
> `sysctl -w security.pax.mprotect.debug=1' will make the kernel print the PID
> and COMM of the process it rejected:
>
> https://github.com/NetBSD/src/blob/trunk/sys/kern/kern_pax.c#L451
>
> That should tell you which process also needs `paxctl +m' in Wine 11.
>
> -RVP
Home |
Main Index |
Thread Index |
Old Index