Skip to content

Instantly share code, notes, and snippets.

@Kadalis
Last active August 1, 2023 17:57
Show Gist options
  • Save Kadalis/07cc708c7fb66c12f2af2eae05d0d6ea to your computer and use it in GitHub Desktop.
Save Kadalis/07cc708c7fb66c12f2af2eae05d0d6ea to your computer and use it in GitHub Desktop.
dirty fix for dbus capabilities drop "Operation not permitted" error. IDK why zeroing ambient capabilities helps, same as I don't know what else does it affect.
diff --git a/kernel/core_hook.c b/kernel/core_hook.c
index 83413b47..70f7cdf7 100644
--- a/kernel/core_hook.c
+++ b/kernel/core_hook.c
@@ -134,6 +134,10 @@ void escape_to_root(void)
memcpy(&cred->cap_ambient, &profile->capabilities.effective,
sizeof(cred->cap_ambient));
+ // set ambient caps to all-zero
+ // fixes "operation not permitted" on dbus cap dropping
+ memset(&cred->cap_ambient, 0, sizeof(cred->cap_ambient));
+
// disable seccomp
#if defined(CONFIG_GENERIC_ENTRY) && \
LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment