2016-10-19 03:17:52 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2016, The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2017-08-21 23:31:17 +02:00
|
|
|
#include <signal.h>
|
2016-10-19 03:17:52 +02:00
|
|
|
#include <stdint.h>
|
2017-08-21 23:31:17 +02:00
|
|
|
#include <sys/ucontext.h>
|
|
|
|
#include <unistd.h>
|
2016-10-19 03:17:52 +02:00
|
|
|
|
2017-05-24 16:07:25 +02:00
|
|
|
#include "dump_type.h"
|
|
|
|
|
2016-10-19 03:17:52 +02:00
|
|
|
// Sockets in the ANDROID_SOCKET_NAMESPACE_RESERVED namespace.
|
|
|
|
// Both sockets are SOCK_SEQPACKET sockets, so no explicit length field is needed.
|
|
|
|
constexpr char kTombstonedCrashSocketName[] = "tombstoned_crash";
|
2017-05-15 16:59:30 +02:00
|
|
|
constexpr char kTombstonedJavaTraceSocketName[] = "tombstoned_java_trace";
|
2016-10-19 03:17:52 +02:00
|
|
|
constexpr char kTombstonedInterceptSocketName[] = "tombstoned_intercept";
|
|
|
|
|
|
|
|
enum class CrashPacketType : uint8_t {
|
|
|
|
// Initial request from crash_dump.
|
|
|
|
kDumpRequest = 0,
|
|
|
|
|
|
|
|
// Notification of a completed crash dump.
|
|
|
|
// Sent after a dump is completed and the process has been untraced, but
|
|
|
|
// before it has been resumed with SIGCONT.
|
|
|
|
kCompletedDump,
|
|
|
|
|
|
|
|
// Responses to kRequest.
|
|
|
|
// kPerformDump sends along an output fd via cmsg(3).
|
|
|
|
kPerformDump = 128,
|
|
|
|
kAbortDump,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DumpRequest {
|
2017-05-24 16:07:25 +02:00
|
|
|
DebuggerdDumpType dump_type;
|
2016-10-19 03:17:52 +02:00
|
|
|
int32_t pid;
|
|
|
|
};
|
|
|
|
|
|
|
|
// The full packet must always be written, regardless of whether the union is used.
|
|
|
|
struct TombstonedCrashPacket {
|
|
|
|
CrashPacketType packet_type;
|
|
|
|
union {
|
|
|
|
DumpRequest dump_request;
|
|
|
|
} packet;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Comes with a file descriptor via SCM_RIGHTS.
|
|
|
|
// This packet should be sent before an actual dump happens.
|
|
|
|
struct InterceptRequest {
|
2017-05-24 16:07:25 +02:00
|
|
|
DebuggerdDumpType dump_type;
|
2016-10-19 03:17:52 +02:00
|
|
|
int32_t pid;
|
|
|
|
};
|
|
|
|
|
2017-03-31 01:40:47 +02:00
|
|
|
enum class InterceptStatus : uint8_t {
|
2023-10-17 04:14:28 +02:00
|
|
|
// Returned when an intercept of the same type has already been
|
2017-05-24 16:07:25 +02:00
|
|
|
// registered (and is active) for a given PID.
|
|
|
|
kFailedAlreadyRegistered,
|
|
|
|
// Returned in all other failure cases.
|
2017-03-31 01:40:47 +02:00
|
|
|
kFailed,
|
|
|
|
kStarted,
|
|
|
|
kRegistered,
|
|
|
|
};
|
|
|
|
|
2016-10-19 03:17:52 +02:00
|
|
|
// Sent either immediately upon failure, or when the intercept has been used.
|
|
|
|
struct InterceptResponse {
|
2017-03-31 01:40:47 +02:00
|
|
|
InterceptStatus status;
|
2016-10-19 03:17:52 +02:00
|
|
|
char error_message[127]; // always null-terminated
|
|
|
|
};
|
2017-08-21 23:31:17 +02:00
|
|
|
|
|
|
|
// Sent from handler to crash_dump via pipe.
|
2018-08-07 00:38:29 +02:00
|
|
|
struct __attribute__((__packed__)) CrashInfoHeader {
|
|
|
|
uint32_t version;
|
|
|
|
};
|
|
|
|
|
2020-03-06 01:46:15 +01:00
|
|
|
struct __attribute__((__packed__)) CrashInfoDataStatic {
|
2017-08-21 23:31:17 +02:00
|
|
|
siginfo_t siginfo;
|
|
|
|
ucontext_t ucontext;
|
|
|
|
uintptr_t abort_msg_address;
|
|
|
|
};
|
2018-08-07 00:38:29 +02:00
|
|
|
|
2020-03-06 01:46:15 +01:00
|
|
|
struct __attribute__((__packed__)) CrashInfoDataDynamic : public CrashInfoDataStatic {
|
2018-08-07 00:38:29 +02:00
|
|
|
uintptr_t fdsan_table_address;
|
2020-02-14 23:54:31 +01:00
|
|
|
uintptr_t gwp_asan_state;
|
|
|
|
uintptr_t gwp_asan_metadata;
|
2020-04-07 23:07:32 +02:00
|
|
|
uintptr_t scudo_stack_depot;
|
|
|
|
uintptr_t scudo_region_info;
|
2021-01-07 06:02:19 +01:00
|
|
|
uintptr_t scudo_ring_buffer;
|
2022-12-23 01:15:23 +01:00
|
|
|
size_t scudo_ring_buffer_size;
|
2023-12-05 01:39:15 +01:00
|
|
|
size_t scudo_stack_depot_size;
|
2024-03-14 14:18:47 +01:00
|
|
|
bool recoverable_crash;
|
2024-02-08 01:42:23 +01:00
|
|
|
uintptr_t crash_detail_page;
|
2020-02-14 23:54:31 +01:00
|
|
|
};
|
|
|
|
|
2018-08-07 00:38:29 +02:00
|
|
|
struct __attribute__((__packed__)) CrashInfo {
|
|
|
|
CrashInfoHeader header;
|
|
|
|
union {
|
2020-03-06 01:46:15 +01:00
|
|
|
CrashInfoDataStatic s;
|
|
|
|
CrashInfoDataDynamic d;
|
2018-08-07 00:38:29 +02:00
|
|
|
} data;
|
|
|
|
};
|