Merge "init.rc: Perform some mounts with nodev,nosuid,noexec"
diff --git a/adb/jdwp_service.cpp b/adb/jdwp_service.cpp
index 0a8a85a..7adbf2d 100644
--- a/adb/jdwp_service.cpp
+++ b/adb/jdwp_service.cpp
@@ -453,7 +453,7 @@
**/
struct JdwpSocket : public asocket {
- bool pass;
+ bool pass = false;
};
static void jdwp_socket_close(asocket* s) {
@@ -467,7 +467,7 @@
}
remove_socket(s);
- free(s);
+ delete s;
}
static int jdwp_socket_enqueue(asocket* s, std::string) {
@@ -497,7 +497,7 @@
}
asocket* create_jdwp_service_socket(void) {
- JdwpSocket* s = reinterpret_cast<JdwpSocket*>(calloc(sizeof(*s), 1));
+ JdwpSocket* s = new JdwpSocket();
if (!s) {
fatal("failed to allocate JdwpSocket");
diff --git a/adb/socket.h b/adb/socket.h
index a1b52b3..2f09080 100644
--- a/adb/socket.h
+++ b/adb/socket.h
@@ -36,31 +36,31 @@
struct asocket {
/* the unique identifier for this asocket
*/
- unsigned id;
+ unsigned id = 0;
/* flag: set when the socket's peer has closed
* but packets are still queued for delivery
*/
- int closing;
+ int closing = 0;
// flag: set when the socket failed to write, so the socket will not wait to
// write packets and close directly.
- bool has_write_error;
+ bool has_write_error = 0;
/* flag: quit adbd when both ends close the
* local service socket
*/
- int exit_on_close;
+ int exit_on_close = 0;
// the asocket we are connected to
- asocket* peer;
+ asocket* peer = nullptr;
/* For local asockets, the fde is used to bind
* us to our fd event system. For remote asockets
* these fields are not used.
*/
- fdevent fde;
- int fd;
+ fdevent fde = {};
+ int fd = 0;
// queue of data waiting to be written
std::deque<Range> packet_queue;
@@ -73,27 +73,27 @@
* peer->ready() when we once again are ready to
* receive data.
*/
- int (*enqueue)(asocket* s, std::string data);
+ int (*enqueue)(asocket* s, std::string data) = nullptr;
/* ready is called by the peer when it is ready for
* us to send data via enqueue again
*/
- void (*ready)(asocket* s);
+ void (*ready)(asocket* s) = nullptr;
/* shutdown is called by the peer before it goes away.
* the socket should not do any further calls on its peer.
* Always followed by a call to close. Optional, i.e. can be NULL.
*/
- void (*shutdown)(asocket* s);
+ void (*shutdown)(asocket* s) = nullptr;
/* close is called by the peer when it has gone away.
* we are not allowed to make any further calls on the
* peer once our close method is called.
*/
- void (*close)(asocket* s);
+ void (*close)(asocket* s) = nullptr;
/* A socket is bound to atransport */
- atransport* transport;
+ atransport* transport = nullptr;
size_t get_max_payload() const;
};
diff --git a/adb/sockets.cpp b/adb/sockets.cpp
index e9c45b7..307cbfe 100644
--- a/adb/sockets.cpp
+++ b/adb/sockets.cpp
@@ -170,7 +170,7 @@
fdevent_remove(&s->fde);
remove_socket(s);
- free(s);
+ delete s;
if (exit_on_close) {
D("local_socket_destroy: exiting");
@@ -347,10 +347,7 @@
}
asocket* create_local_socket(int fd) {
- asocket* s = reinterpret_cast<asocket*>(calloc(1, sizeof(asocket)));
- if (s == NULL) {
- fatal("cannot allocate socket");
- }
+ asocket* s = new asocket();
s->fd = fd;
s->enqueue = local_socket_enqueue;
s->ready = local_socket_ready;
@@ -459,7 +456,7 @@
D("entered remote_socket_close RS(%d) CLOSE fd=%d peer->fd=%d", s->id, s->fd,
s->peer ? s->peer->fd : -1);
D("RS(%d): closed", s->id);
- free(s);
+ delete s;
}
// Create a remote socket to exchange packets with a remote service through transport
@@ -470,11 +467,7 @@
if (id == 0) {
fatal("invalid remote socket id (0)");
}
- asocket* s = reinterpret_cast<asocket*>(calloc(1, sizeof(asocket)));
-
- if (s == NULL) {
- fatal("cannot allocate socket");
- }
+ asocket* s = new asocket();
s->id = id;
s->enqueue = remote_socket_enqueue;
s->ready = remote_socket_ready;
@@ -811,13 +804,12 @@
s->peer->close(s->peer);
s->peer = 0;
}
- free(s);
+ delete s;
}
static asocket* create_smart_socket(void) {
D("Creating smart socket");
- asocket* s = reinterpret_cast<asocket*>(calloc(1, sizeof(asocket)));
- if (s == NULL) fatal("cannot allocate socket");
+ asocket* s = new asocket();
s->enqueue = smart_socket_enqueue;
s->ready = smart_socket_ready;
s->shutdown = NULL;
diff --git a/adb/transport.cpp b/adb/transport.cpp
index 3b0669c..9ae1297 100644
--- a/adb/transport.cpp
+++ b/adb/transport.cpp
@@ -378,9 +378,9 @@
*/
struct device_tracker {
asocket socket;
- bool update_needed;
- bool long_output;
- device_tracker* next;
+ bool update_needed = false;
+ bool long_output = false;
+ device_tracker* next = nullptr;
};
/* linked list of all device trackers */
@@ -411,7 +411,7 @@
peer->close(peer);
}
device_tracker_remove(tracker);
- free(tracker);
+ delete tracker;
}
static int device_tracker_enqueue(asocket* socket, std::string) {
@@ -446,7 +446,7 @@
}
asocket* create_device_tracker(bool long_output) {
- device_tracker* tracker = reinterpret_cast<device_tracker*>(calloc(1, sizeof(*tracker)));
+ device_tracker* tracker = new device_tracker();
if (tracker == nullptr) fatal("cannot allocate device tracker");
D("device tracker %p created", tracker);
diff --git a/libcutils/trace-dev.inc b/libcutils/trace-dev.inc
index f32330a..f95c6c5 100644
--- a/libcutils/trace-dev.inc
+++ b/libcutils/trace-dev.inc
@@ -70,7 +70,7 @@
for (int i = 0; i < count; i++) {
snprintf(buf, sizeof(buf), "debug.atrace.app_%d", i);
property_get(buf, value, "");
- if (strcmp(value, cmdline) == 0) {
+ if (strcmp(value, "*") == 0 || strcmp(value, cmdline) == 0) {
return true;
}
}
diff --git a/libunwindstack/Unwinder.cpp b/libunwindstack/Unwinder.cpp
index dfd7b18..5e32933 100644
--- a/libunwindstack/Unwinder.cpp
+++ b/libunwindstack/Unwinder.cpp
@@ -91,7 +91,7 @@
return;
}
- frame->pc = map_info->start + adjusted_rel_pc;
+ frame->pc = map_info->start + adjusted_rel_pc - elf->GetLoadBias() - map_info->elf_offset;
frame->map_name = map_info->name;
frame->map_offset = map_info->offset;
frame->map_start = map_info->start;
diff --git a/libunwindstack/tests/UnwinderTest.cpp b/libunwindstack/tests/UnwinderTest.cpp
index 7358ae6..7fbae4c 100644
--- a/libunwindstack/tests/UnwinderTest.cpp
+++ b/libunwindstack/tests/UnwinderTest.cpp
@@ -102,6 +102,22 @@
info->load_bias = 0;
maps_.FakeAddMapInfo(info);
+ info = new MapInfo(0xa5000, 0xa6000, 0, PROT_READ | PROT_WRITE | PROT_EXEC,
+ "/fake/fake_load_bias.so");
+ elf = new ElfFake(new MemoryFake);
+ info->elf.reset(elf);
+ elf->FakeSetInterface(new ElfInterfaceFake(nullptr));
+ elf->FakeSetLoadBias(0x5000);
+ maps_.FakeAddMapInfo(info);
+
+ info = new MapInfo(0xa7000, 0xa8000, 0, PROT_READ | PROT_WRITE | PROT_EXEC,
+ "/fake/fake_offset.oat");
+ elf = new ElfFake(new MemoryFake);
+ info->elf.reset(elf);
+ elf->FakeSetInterface(new ElfInterfaceFake(nullptr));
+ info->elf_offset = 0x8000;
+ maps_.FakeAddMapInfo(info);
+
process_memory_.reset(new MemoryFake);
}
@@ -180,6 +196,62 @@
EXPECT_EQ(PROT_READ | PROT_WRITE, frame->map_flags);
}
+TEST_F(UnwinderTest, non_zero_load_bias) {
+ ElfInterfaceFake::FakePushFunctionData(FunctionData("Frame0", 0));
+
+ regs_.FakeSetPc(0xa5500);
+ regs_.FakeSetSp(0x10000);
+ ElfInterfaceFake::FakePushStepData(StepData(0, 0, true));
+
+ Unwinder unwinder(64, &maps_, ®s_, process_memory_);
+ unwinder.Unwind();
+ EXPECT_EQ(ERROR_NONE, unwinder.LastErrorCode());
+
+ ASSERT_EQ(1U, unwinder.NumFrames());
+
+ auto* frame = &unwinder.frames()[0];
+ EXPECT_EQ(0U, frame->num);
+ EXPECT_EQ(0x5500U, frame->rel_pc);
+ EXPECT_EQ(0xa5500U, frame->pc);
+ EXPECT_EQ(0x10000U, frame->sp);
+ EXPECT_EQ("Frame0", frame->function_name);
+ EXPECT_EQ(0U, frame->function_offset);
+ EXPECT_EQ("/fake/fake_load_bias.so", frame->map_name);
+ EXPECT_EQ(0U, frame->map_offset);
+ EXPECT_EQ(0xa5000U, frame->map_start);
+ EXPECT_EQ(0xa6000U, frame->map_end);
+ EXPECT_EQ(0x5000U, frame->map_load_bias);
+ EXPECT_EQ(PROT_READ | PROT_WRITE | PROT_EXEC, frame->map_flags);
+}
+
+TEST_F(UnwinderTest, non_zero_elf_offset) {
+ ElfInterfaceFake::FakePushFunctionData(FunctionData("Frame0", 0));
+
+ regs_.FakeSetPc(0xa7500);
+ regs_.FakeSetSp(0x10000);
+ ElfInterfaceFake::FakePushStepData(StepData(0, 0, true));
+
+ Unwinder unwinder(64, &maps_, ®s_, process_memory_);
+ unwinder.Unwind();
+ EXPECT_EQ(ERROR_NONE, unwinder.LastErrorCode());
+
+ ASSERT_EQ(1U, unwinder.NumFrames());
+
+ auto* frame = &unwinder.frames()[0];
+ EXPECT_EQ(0U, frame->num);
+ EXPECT_EQ(0x8500U, frame->rel_pc);
+ EXPECT_EQ(0xa7500U, frame->pc);
+ EXPECT_EQ(0x10000U, frame->sp);
+ EXPECT_EQ("Frame0", frame->function_name);
+ EXPECT_EQ(0U, frame->function_offset);
+ EXPECT_EQ("/fake/fake_offset.oat", frame->map_name);
+ EXPECT_EQ(0U, frame->map_offset);
+ EXPECT_EQ(0xa7000U, frame->map_start);
+ EXPECT_EQ(0xa8000U, frame->map_end);
+ EXPECT_EQ(0U, frame->map_load_bias);
+ EXPECT_EQ(PROT_READ | PROT_WRITE | PROT_EXEC, frame->map_flags);
+}
+
TEST_F(UnwinderTest, non_zero_map_offset) {
ElfInterfaceFake::FakePushFunctionData(FunctionData("Frame0", 0));
diff --git a/libusbhost/usbhost.c b/libusbhost/usbhost.c
index fa0191b..cb8d430 100644
--- a/libusbhost/usbhost.c
+++ b/libusbhost/usbhost.c
@@ -64,10 +64,6 @@
// Some devices fail to send string descriptors if we attempt reading > 255 bytes
#define MAX_STRING_DESCRIPTOR_LENGTH 255
-// From drivers/usb/core/devio.c
-// I don't know why this isn't in a kernel header
-#define MAX_USBFS_BUFFER_SIZE 16384
-
#define MAX_USBFS_WD_COUNT 10
struct usb_host_context {
@@ -664,10 +660,6 @@
{
struct usbdevfs_bulktransfer ctrl;
- // need to limit request size to avoid EINVAL
- if (length > MAX_USBFS_BUFFER_SIZE)
- length = MAX_USBFS_BUFFER_SIZE;
-
memset(&ctrl, 0, sizeof(ctrl));
ctrl.ep = endpoint;
ctrl.len = length;
@@ -727,11 +719,7 @@
urb->status = -1;
urb->buffer = req->buffer;
- // need to limit request size to avoid EINVAL
- if (req->buffer_length > MAX_USBFS_BUFFER_SIZE)
- urb->buffer_length = MAX_USBFS_BUFFER_SIZE;
- else
- urb->buffer_length = req->buffer_length;
+ urb->buffer_length = req->buffer_length;
do {
res = ioctl(req->dev->fd, USBDEVFS_SUBMITURB, urb);