Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeBSD 13 memory mapping policy allow_wx=0 causes crash #1730

Closed
richnetdesign opened this issue Jun 4, 2021 · 6 comments
Closed

FreeBSD 13 memory mapping policy allow_wx=0 causes crash #1730

richnetdesign opened this issue Jun 4, 2021 · 6 comments

Comments

@richnetdesign
Copy link

richnetdesign commented Jun 4, 2021

I'm using FreeBSD 13 on a network appliance, with dnscrypt-proxy installed. A new security feature in FreeBSD 13 is "W^X memory mapping policy for user processes". In other words "disallow pages to be executable and writable".

To enable the mitigation
sysctl kern.elf64.allow_wx=0

So I wanted to try it out, and most of my programs worked. However, the app crashes
exec_new_vmspace: mapping stack size 0x20000000 prot 0x7 failed mach error 2 errno 13 Abort trap

Output of the following commands:

./dnscrypt-proxy -version
2.0.45

./dnscrypt-proxy -check

What is affected by this bug?

Crashes on start

When does this occur?

When starting dnscrypt-proxy it crashes with
exec_new_vmspace: mapping stack size 0x20000000 prot 0x7 failed mach error 2 errno 13 Abort trap

Changing the sysctl back restores functionality.

Where does it happen?

FreeBSD 13

Expected behavior (i.e. solution)

Normal functionality

Other Comments

I can help investigate this. Wanted to put it out there and get feedback first. While this is a new feature in FreeBSD, I believe OpenBSD has had it for awhile so perhaps something to reference.

References

https://ximalas.info/2021/04/15/freebsd-13-and-wx-memory-mapping-policy-for-user-processes/

@jedisct1
Copy link
Member

jedisct1 commented Jun 4, 2021

Looks like +wxneeded needs to be set on programs written in Go: https://forums.freebsd.org/threads/rclone-not-working-with-w-x.80279/

@jedisct1
Copy link
Member

jedisct1 commented Jun 4, 2021

I don't think there's much that can be done by applications themselves. This needs to be fixed in Go.

@richnetdesign
Copy link
Author

That rclone thread is very helpful. I'll be sure to search freebsd forums in the future.
Now to track down if Go has this on there roadmap.

Seems like there might be 2 seperate issues.

  1. Go / compile toolchain issue is causing elf to be missing header. This prevents elfctl from configure binary to deviate from global W^X config.
  2. Executables compiled with Go crash immediately if W^X enabled.

@igalic
Copy link

igalic commented Sep 1, 2021

given that this is a Go runtime issue, I've opened a ticket in Go: golang/go#48112

@jedisct1
Copy link
Member

jedisct1 commented Sep 1, 2021

Awesome, thank you!

@richnetdesign
Copy link
Author

richnetdesign commented Sep 2, 2021

I forgot about this. Thanks everybody it seems to be getting fixed upstream in Go, so perhaps I can set allow_wx=0 on my network appliance again soon.

@DNSCrypt DNSCrypt locked and limited conversation to collaborators Oct 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants