Merge "Set security context of /adb_keys and /data/misc/adb/adb_keys."
diff --git a/adb/framebuffer_service.c b/adb/framebuffer_service.c
index 20c08d2..fa7fd98 100644
--- a/adb/framebuffer_service.c
+++ b/adb/framebuffer_service.c
@@ -55,13 +55,13 @@
void framebuffer_service(int fd, void *cookie)
{
struct fbinfo fbinfo;
- unsigned int i;
+ unsigned int i, bsize;
char buf[640];
int fd_screencap;
int w, h, f;
int fds[2];
- if (pipe(fds) < 0) goto done;
+ if (pipe(fds) < 0) goto pipefail;
pid_t pid = fork();
if (pid < 0) goto done;
@@ -164,17 +164,19 @@
if(writex(fd, &fbinfo, sizeof(fbinfo))) goto done;
/* write data */
- for(i = 0; i < fbinfo.size; i += sizeof(buf)) {
- if(readx(fd_screencap, buf, sizeof(buf))) goto done;
- if(writex(fd, buf, sizeof(buf))) goto done;
+ for(i = 0; i < fbinfo.size; i += bsize) {
+ bsize = sizeof(buf);
+ if (i + bsize > fbinfo.size)
+ bsize = fbinfo.size - i;
+ if(readx(fd_screencap, buf, bsize)) goto done;
+ if(writex(fd, buf, bsize)) goto done;
}
- if(readx(fd_screencap, buf, fbinfo.size % sizeof(buf))) goto done;
- if(writex(fd, buf, fbinfo.size % sizeof(buf))) goto done;
done:
TEMP_FAILURE_RETRY(waitpid(pid, NULL, 0));
close(fds[0]);
close(fds[1]);
+pipefail:
close(fd);
}
diff --git a/libbacktrace/Android.mk b/libbacktrace/Android.mk
index f7b084d..4197bbb 100644
--- a/libbacktrace/Android.mk
+++ b/libbacktrace/Android.mk
@@ -63,38 +63,6 @@
include $(BUILD_SHARED_LIBRARY)
#----------------------------------------------------------------------------
-# The host libbacktrace library using libcorkscrew
-#----------------------------------------------------------------------------
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES += \
- corkscrew.c \
- common.c \
- demangle.c \
- map_info.c \
-
-LOCAL_CFLAGS += \
- -Wall \
- -Wno-unused-parameter \
- -Werror \
- -std=gnu99 \
-
-LOCAL_SHARED_LIBRARIES := \
- liblog \
- libcorkscrew \
- libgccdemangle \
- liblog \
-
-LOCAL_LDLIBS += \
- -ldl \
- -lrt \
-
-LOCAL_MODULE := libbacktrace
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_HOST_SHARED_LIBRARY)
-
-#----------------------------------------------------------------------------
# libbacktrace test library, all optimizations turned off
#----------------------------------------------------------------------------
include $(CLEAR_VARS)
@@ -137,6 +105,38 @@
ifeq ($(HOST_OS)-$(HOST_ARCH),linux-x86)
#----------------------------------------------------------------------------
+# The host libbacktrace library using libcorkscrew
+#----------------------------------------------------------------------------
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES += \
+ corkscrew.c \
+ common.c \
+ demangle.c \
+ map_info.c \
+
+LOCAL_CFLAGS += \
+ -Wall \
+ -Wno-unused-parameter \
+ -Werror \
+ -std=gnu99 \
+
+LOCAL_SHARED_LIBRARIES := \
+ liblog \
+ libcorkscrew \
+ libgccdemangle \
+ liblog \
+
+LOCAL_LDLIBS += \
+ -ldl \
+ -lrt \
+
+LOCAL_MODULE := libbacktrace
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_HOST_SHARED_LIBRARY)
+
+#----------------------------------------------------------------------------
# libbacktrace host test library, all optimizations turned off
#----------------------------------------------------------------------------
include $(CLEAR_VARS)
diff --git a/libbacktrace/backtrace_test.c b/libbacktrace/backtrace_test.c
index 34d3519..6155c9b 100644
--- a/libbacktrace/backtrace_test.c
+++ b/libbacktrace/backtrace_test.c
@@ -22,6 +22,7 @@
#include <signal.h>
#include <sys/ptrace.h>
#include <sys/wait.h>
+#include <errno.h>
#include <unistd.h>
#include <inttypes.h>
@@ -29,6 +30,8 @@
#define FINISH(pid) dump_frames(&backtrace); if (pid < 0) exit(1); else return false;
+#define WAIT_INTERVAL_USECS 1000
+
// Prototypes for functions in the test library.
int test_level_one(int, int, int, int, bool (*)(pid_t));
@@ -52,6 +55,21 @@
}
}
+void wait_for_stop(pid_t pid, size_t max_usecs_to_wait) {
+ siginfo_t si;
+ size_t usecs_waited = 0;
+
+ while (ptrace(PTRACE_GETSIGINFO, pid, 0, &si) < 0 && (errno == EINTR || errno == ESRCH)) {
+ if (usecs_waited >= max_usecs_to_wait) {
+ printf("The process did not get to a stopping point in %zu usecs.\n",
+ usecs_waited);
+ break;
+ }
+ usleep(WAIT_INTERVAL_USECS);
+ usecs_waited += WAIT_INTERVAL_USECS;
+ }
+}
+
bool check_frame(const backtrace_t* backtrace, size_t frame_num,
const char* expected_name) {
if (backtrace->frames[frame_num].proc_name == NULL) {
@@ -153,6 +171,10 @@
kill(pid, SIGKILL);
exit(1);
}
+
+ // Wait up to 1 second for the process to get to a point that we can trace it.
+ wait_for_stop(pid, 1000000);
+
bool pass = verify_func(pid);
if (ptrace(PTRACE_DETACH, pid, 0, 0) != 0) {
printf("Failed to detach from pid %d\n", pid);
diff --git a/libbacktrace/unwind_local.c b/libbacktrace/unwind_local.c
index e0b72d8..d467d8a 100644
--- a/libbacktrace/unwind_local.c
+++ b/libbacktrace/unwind_local.c
@@ -48,6 +48,7 @@
bool returnValue = true;
backtrace->num_frames = 0;
uintptr_t map_start;
+ unw_word_t value;
do {
frame = &backtrace->frames[backtrace->num_frames];
frame->stack_size = 0;
@@ -56,18 +57,21 @@
frame->proc_name = NULL;
frame->proc_offset = 0;
- ret = unw_get_reg(&cursor, UNW_REG_IP, &frame->pc);
+ ret = unw_get_reg(&cursor, UNW_REG_IP, &value);
if (ret < 0) {
ALOGW("get_frames: Failed to read IP %d\n", ret);
returnValue = false;
break;
}
- ret = unw_get_reg(&cursor, UNW_REG_SP, &frame->sp);
+ frame->pc = (uintptr_t)value;
+ ret = unw_get_reg(&cursor, UNW_REG_SP, &value);
if (ret < 0) {
ALOGW("get_frames: Failed to read IP %d\n", ret);
returnValue = false;
break;
}
+ frame->sp = (uintptr_t)value;
+
if (backtrace->num_frames) {
backtrace_frame_data_t* prev = &backtrace->frames[backtrace->num_frames-1];
prev->stack_size = frame->sp - prev->sp;
@@ -111,8 +115,11 @@
unw_context_t* context = (unw_context_t*)backtrace->private_data;
char buf[512];
+ *offset = 0;
+ unw_word_t value;
if (unw_get_proc_name_by_ip(unw_local_addr_space, pc, buf, sizeof(buf),
- offset, context) >= 0 && buf[0] != '\0') {
+ &value, context) >= 0 && buf[0] != '\0') {
+ *offset = (uintptr_t)value;
char* symbol = demangle_symbol_name(buf);
if (!symbol) {
symbol = strdup(buf);
diff --git a/libbacktrace/unwind_remote.c b/libbacktrace/unwind_remote.c
index ebbde2e..1c624d7 100644
--- a/libbacktrace/unwind_remote.c
+++ b/libbacktrace/unwind_remote.c
@@ -46,6 +46,7 @@
bool returnValue = true;
backtrace->num_frames = 0;
uintptr_t map_start;
+ unw_word_t value;
do {
frame = &backtrace->frames[backtrace->num_frames];
frame->stack_size = 0;
@@ -54,18 +55,21 @@
frame->proc_name = NULL;
frame->proc_offset = 0;
- ret = unw_get_reg(&cursor, UNW_REG_IP, &frame->pc);
+ ret = unw_get_reg(&cursor, UNW_REG_IP, &value);
if (ret < 0) {
ALOGW("remote_get_frames: Failed to read IP %d\n", ret);
returnValue = false;
break;
}
- ret = unw_get_reg(&cursor, UNW_REG_SP, &frame->sp);
+ frame->pc = (uintptr_t)value;
+ ret = unw_get_reg(&cursor, UNW_REG_SP, &value);
if (ret < 0) {
ALOGW("remote_get_frames: Failed to read SP %d\n", ret);
returnValue = false;
break;
}
+ frame->sp = (uintptr_t)value;
+
if (backtrace->num_frames) {
backtrace_frame_data_t* prev = &backtrace->frames[backtrace->num_frames-1];
prev->stack_size = frame->sp - prev->sp;
@@ -139,8 +143,11 @@
backtrace_private_t* data = (backtrace_private_t*)backtrace->private_data;
char buf[512];
- if (unw_get_proc_name_by_ip(data->addr_space, pc, buf, sizeof(buf), offset,
+ *offset = 0;
+ unw_word_t value;
+ if (unw_get_proc_name_by_ip(data->addr_space, pc, buf, sizeof(buf), &value,
data->upt_info) >= 0 && buf[0] != '\0') {
+ *offset = (uintptr_t)value;
char* symbol = demangle_symbol_name(buf);
if (!symbol) {
symbol = strdup(buf);
diff --git a/rootdir/ueventd.rc b/rootdir/ueventd.rc
index 2cf0265..a60cfc5 100644
--- a/rootdir/ueventd.rc
+++ b/rootdir/ueventd.rc
@@ -5,6 +5,8 @@
/dev/tty 0666 root root
/dev/random 0666 root root
/dev/urandom 0666 root root
+# Make HW RNG readable by group system to let EntropyMixer read it.
+/dev/hw_random 0440 root system
/dev/ashmem 0666 root root
/dev/binder 0666 root root