Fix capability setting for the top 32 bits.
Bug: 11508244
Change-Id: I83523dfef9946466e1628c461915dac00769c03d
diff --git a/runtime/native/dalvik_system_Zygote.cc b/runtime/native/dalvik_system_Zygote.cc
index d065ee4..dac2c89 100644
--- a/runtime/native/dalvik_system_Zygote.cc
+++ b/runtime/native/dalvik_system_Zygote.cc
@@ -230,18 +230,18 @@
static void SetCapabilities(int64_t permitted, int64_t effective) {
__user_cap_header_struct capheader;
- __user_cap_data_struct capdata;
-
memset(&capheader, 0, sizeof(capheader));
- memset(&capdata, 0, sizeof(capdata));
-
- capheader.version = _LINUX_CAPABILITY_VERSION;
+ capheader.version = _LINUX_CAPABILITY_VERSION_3;
capheader.pid = 0;
- capdata.effective = effective;
- capdata.permitted = permitted;
+ __user_cap_data_struct capdata[2];
+ memset(&capdata, 0, sizeof(capdata));
+ capdata[0].effective = effective;
+ capdata[1].effective = effective >> 32;
+ capdata[0].permitted = permitted;
+ capdata[1].permitted = permitted >> 32;
- if (capset(&capheader, &capdata) != 0) {
+ if (capset(&capheader, &capdata[0]) == -1) {
PLOG(FATAL) << "capset(" << permitted << ", " << effective << ") failed";
}
}