From 5ad965bf41a22929afc4d79fd1988416c192a6a6 Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Thu, 16 Feb 2017 19:22:25 -0800 Subject: [PATCH] crash_dump: fix overflow. `1 << 32` overflows, resulting in bogus PR_CAP_AMBIENT_RAISE attempts, and breaking dumping for processes with capabilities in the top 32 bits. Bug: http://b/35241370 Test: debuggerd -b `pidof com.android.bluetooth` Change-Id: I29c45a8bd36bdeb3492c9f74599993c139821088 --- debuggerd/handler/debuggerd_handler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debuggerd/handler/debuggerd_handler.cpp b/debuggerd/handler/debuggerd_handler.cpp index 680ba4bee..67c26e2f4 100644 --- a/debuggerd/handler/debuggerd_handler.cpp +++ b/debuggerd/handler/debuggerd_handler.cpp @@ -202,7 +202,7 @@ static void raise_caps() { uint64_t capmask = capdata[0].inheritable; capmask |= static_cast(capdata[1].inheritable) << 32; for (unsigned long i = 0; i < 64; ++i) { - if (capmask & (1 << i)) { + if (capmask & (1ULL << i)) { if (prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE, i, 0, 0) != 0) { __libc_format_log(ANDROID_LOG_ERROR, "libc", "failed to raise ambient capability %lu: %s", i, strerror(errno));