Skip to content

apply hardened_malloc opt-out to app process children; override value of /proc/self/attr/prev for exec spawning - #412

Merged
thestinger merged 11 commits into
GrapheneOS:17from
muhomorr:17_07-19_base
Jul 28, 2026
Merged

apply hardened_malloc opt-out to app process children; override value of /proc/self/attr/prev for exec spawning#412
thestinger merged 11 commits into
GrapheneOS:17from
muhomorr:17_07-19_base

Conversation

@muhomorr

@muhomorr muhomorr commented Jul 19, 2026

Copy link
Copy Markdown
Member

Comment on lines +65 to +67
final boolean useHardenedMalloc = AswUseHardenedMalloc.I.get(ctx, userId, appInfo, ps);
final boolean useZygoteSpawning = !AswUseExecSpawning.I.get(ctx, userId, appInfo, ps)
&& ((zygotePolicyFlags & ZYGOTE_POLICY_FLAG_NATIVE_PROCESS) == 0 || useHardenedMalloc);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds a second reason for native processes to use exec spawning, but com.android.server.am.ActiveServices still uses only AswUseExecSpawning when deciding whether to create an app zygote and attach appInfoForPreloading. Should probably refactor

https://github.com/muhomorr/platform_frameworks_base/blob/63bf418225a037df135bd8b7b0de05f2d76b332d/services/core/java/com/android/server/am/ActiveServices.java#L6349

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +77 to +79
// The value of /proc/self/attr/prev is "u:r:zygote:s0" when exec spawning is used.
// Some apps expect the value to be "u:r:init:s0", as is the case under zygote spawning.
res.selinuxFlags |= SELinuxFlags.OVERRIDE_PREV_SELINUX_CTX_TO_INIT;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could also add this to createForWebviewProcess, though an app probably doesn't check this from a WebView

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WebView processes never run Java or native code from their client app AFAIK.

ZygoteExtraArgs and ActiveServices logic was mismatched.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hardened_malloc compat flag not added to explicit child process environments

3 participants