Fix support for named mmap usage on Android
Fix support for named mmap usage on Android

Using a memfd name to annotate swiftshader_jit allocations is quite
clever, but it doesn't work on Android because memfds can be shared
and so writing to mappings of them promotes CoW/shared, which is
classified by selinux as 'execmod' permission. Android prohibits
'execmod' permission for new app processes, because this is usually a
sign the app relies on shared text relocations, which are insecure. In
this case, that isn't actually happening, but we are subject to the
same blanket ban :)

Fortunately, Android has a longtime non-upstreamed prctl() to allow
private mappings to be named as well, PR_SET_VMA_ANON_NAME. As this
isn't generally available for Linux, wrap it in checks for __ANDROID__.

This enables the naming without tripping the 'execmod' permission check.

Bug: b/171498948
Bug: b/174801963
Change-Id: Ic4375bc4407e21ecdafb42a7cec651dc3b2ad13e
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/52669
Reviewed-by: Jason Macnak <76caa58940b8c6785e996f522e85b625ac7c7baa@google.com>
Reviewed-by: Nicolas Capens <51edc787c30f24c4904e8ffbb5523c3a9f7a451d@google.com>
Presubmit-Ready: Jason Macnak <76caa58940b8c6785e996f522e85b625ac7c7baa@google.com>
Tested-by: Jason Macnak <76caa58940b8c6785e996f522e85b625ac7c7baa@google.com>
Kokoro-Result: kokoro <2ac7b1f3fa578934c95181d4272be0d3bca00121@google.com>
Commit-Queue: Jason Macnak <76caa58940b8c6785e996f522e85b625ac7c7baa@google.com>

google/swiftshader,bkaradzic/SwiftShader,google/swiftshader,bkaradzic/SwiftShader,google/swiftshader,bkaradzic/SwiftShader,bkaradzic/SwiftShader,bkaradzic/SwiftShader