blob: 851475738649c194ce867791caedf0d0113b22f4 [file] [log] [blame]
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_BAD_MESSAGE_H_
#define CONTENT_BROWSER_BAD_MESSAGE_H_
#include "base/debug/crash_logging.h"
#include "content/common/content_export.h"
namespace content {
class BrowserMessageFilter;
class RenderProcessHost;
namespace bad_message {
// The browser process often chooses to terminate a renderer if it receives
// a bad IPC message. The reasons are tracked for metrics.
//
// Content embedders should implement their own bad message statistics but
// should use similar histogram names to make analysis easier.
//
// NOTE: Do not remove or reorder elements in this list. Add new entries at the
// end. Items may be renamed but do not change the values. We rely on the enum
// values in histograms.
enum BadMessageReason {
NC_IN_PAGE_NAVIGATION = 0,
RFH_CAN_COMMIT_URL_BLOCKED = 1,
RFH_CAN_ACCESS_FILES_OF_PAGE_STATE = 2,
RFH_SANDBOX_FLAGS = 3,
RFH_NO_PROXY_TO_PARENT = 4,
RPH_DESERIALIZATION_FAILED = 5,
OBSOLETE_RVH_CAN_ACCESS_FILES_OF_PAGE_STATE = 6,
OBSOLETE_RFH_FILE_CHOOSER_PATH = 7,
OBSOLETE_RWH_SYNTHETIC_GESTURE = 8,
OBSOLETE_RWH_FOCUS = 9,
OBSOLETE_RWH_BLUR = 10,
RWH_SHARED_BITMAP = 11,
OBSOLETE_RWH_BAD_ACK_MESSAGE = 12,
OBSOLETE_RWHVA_SHARED_MEMORY = 13,
SERVICE_WORKER_BAD_URL = 14,
OBSOLETE_WC_INVALID_FRAME_SOURCE = 15,
OBSOLETE_RWHVM_UNEXPECTED_FRAME_TYPE = 16,
RFPH_DETACH = 17,
DFH_BAD_EMBEDDER_MESSAGE = 18,
NC_AUTO_SUBFRAME = 19,
CSDH_NOT_RECOGNIZED = 20,
OBSOLETE_DSMF_OPEN_STORAGE = 21,
DSMF_LOAD_STORAGE = 22,
OBSOLETE_DBMF_INVALID_ORIGIN_ON_OPEN = 23,
OBSOLETE_DBMF_DB_NOT_OPEN_ON_MODIFY = 24,
OBSOLETE_DBMF_DB_NOT_OPEN_ON_CLOSE = 25,
OBSOLETE_DBMF_INVALID_ORIGIN_ON_SQLITE_ERROR = 26,
RDH_INVALID_PRIORITY = 27,
OBSOLETE_RDH_REQUEST_NOT_TRANSFERRING = 28,
RDH_BAD_DOWNLOAD = 29,
OBSOLETE_NMF_NO_PERMISSION_SHOW = 30,
OBSOLETE_NMF_NO_PERMISSION_CLOSE = 31,
OBSOLETE_NMF_NO_PERMISSION_VERIFY = 32,
MH_INVALID_MIDI_PORT = 33,
MH_SYS_EX_PERMISSION = 34,
ACDH_REGISTER = 35,
ACDH_UNREGISTER = 36,
ACDH_SET_SPAWNING = 37,
ACDH_SELECT_CACHE = 38,
OBSOLETE_ACDH_SELECT_CACHE_FOR_WORKER = 39,
ACDH_SELECT_CACHE_FOR_SHARED_WORKER = 40,
ACDH_MARK_AS_FOREIGN_ENTRY = 41,
ACDH_PENDING_REPLY_IN_GET_STATUS = 42,
ACDH_GET_STATUS = 43,
ACDH_PENDING_REPLY_IN_START_UPDATE = 44,
ACDH_START_UPDATE = 45,
ACDH_PENDING_REPLY_IN_SWAP_CACHE = 46,
ACDH_SWAP_CACHE = 47,
SWDH_NOT_HANDLED = 48,
OBSOLETE_SWDH_REGISTER_BAD_URL = 49,
OBSOLETE_SWDH_REGISTER_NO_HOST = 50,
OBSOLETE_SWDH_REGISTER_CANNOT = 51,
OBSOLETE_SWDH_UNREGISTER_BAD_URL = 52,
OBSOLETE_SWDH_UNREGISTER_NO_HOST = 53,
OBSOLETE_SWDH_UNREGISTER_CANNOT = 54,
OBSOLETE_SWDH_GET_REGISTRATION_BAD_URL = 55,
OBSOLETE_SWDH_GET_REGISTRATION_NO_HOST = 56,
OBSOLETE_SWDH_GET_REGISTRATION_CANNOT = 57,
OBSOLETE_SWDH_GET_REGISTRATION_FOR_READY_NO_HOST = 58,
OBSOLETE_SWDH_GET_REGISTRATION_FOR_READY_ALREADY_IN_PROGRESS = 59,
SWDH_POST_MESSAGE = 60,
OBSOLETE_SWDH_PROVIDER_CREATED_NO_HOST = 61,
OBSOLETE_SWDH_PROVIDER_DESTROYED_NO_HOST = 62,
OBSOLETE_SWDH_SET_HOSTED_VERSION_NO_HOST = 63,
OBSOLETE_SWDH_SET_HOSTED_VERSION = 64,
OBSOLETE_SWDH_WORKER_SCRIPT_LOAD_NO_HOST = 65,
SWDH_INCREMENT_WORKER_BAD_HANDLE = 66,
SWDH_DECREMENT_WORKER_BAD_HANDLE = 67,
OBSOLETE_SWDH_INCREMENT_REGISTRATION_BAD_HANDLE = 68,
OBSOLETE_SWDH_DECREMENT_REGISTRATION_BAD_HANDLE = 69,
SWDH_TERMINATE_BAD_HANDLE = 70,
OBSOLETE_FAMF_APPEND_ITEM_TO_BLOB = 71,
OBSOLETE_FAMF_APPEND_SHARED_MEMORY_TO_BLOB = 72,
OBSOLETE_FAMF_MALFORMED_STREAM_URL = 73,
OBSOLETE_FAMF_APPEND_ITEM_TO_STREAM = 74,
OBSOLETE_FAMF_APPEND_SHARED_MEMORY_TO_STREAM = 75,
OBSOLETE_IDBDH_CAN_READ_FILE = 76,
OBSOLETE_IDBDH_GET_OR_TERMINATE = 77,
RFMF_SET_COOKIE_BAD_ORIGIN = 78,
RFMF_GET_COOKIES_BAD_ORIGIN = 79,
OBSOLETE_SWDH_GET_REGISTRATIONS_NO_HOST = 80,
OBSOLETE_SWDH_GET_REGISTRATIONS_INVALID_ORIGIN = 81,
OBSOLETE_AOAH_UNAUTHORIZED_URL = 82,
BDH_INVALID_SERVICE_ID = 83,
OBSOLETE_RFH_COMMIT_DESERIALIZATION_FAILED = 84,
BDH_INVALID_CHARACTERISTIC_ID = 85,
OBSOLETE_SWDH_UPDATE_NO_HOST = 86,
OBSOLETE_SWDH_UPDATE_BAD_REGISTRATION_ID = 87,
OBSOLETE_SWDH_UPDATE_CANNOT = 88,
OBSOLETE_SWDH_UNREGISTER_BAD_REGISTRATION_ID = 89,
BDH_INVALID_WRITE_VALUE_LENGTH = 90,
OBSOLETE_WC_MEMORY_CACHE_RESOURCE_BAD_SECURITY_INFO = 91,
OBSOLETE_WC_RENDERER_DID_NAVIGATE_BAD_SECURITY_INFO = 92,
OBSOLETE_BDH_DUPLICATE_REQUEST_DEVICE_ID = 93,
CSDH_INVALID_ORIGIN = 94,
RDH_ILLEGAL_ORIGIN = 95,
OBSOLETE_RDH_UNAUTHORIZED_HEADER_REQUEST = 96,
RDH_INVALID_URL = 97,
OBSOLETE_BDH_CHARACTERISTIC_ALREADY_SUBSCRIBED = 98,
RFH_OWNER_PROPERTY = 99,
OBSOLETE_BDH_EMPTY_OR_INVALID_FILTERS = 100,
OBSOLETE_WC_CONTENT_WITH_CERT_ERRORS_BAD_SECURITY_INFO = 101,
OBSOLETE_RFMF_RENDERER_FAKED_ITS_OWN_DEATH = 102,
DWNLD_INVALID_SAVABLE_RESOURCE_LINKS_RESPONSE = 103,
OBSOLETE_DWNLD_INVALID_SERIALIZE_AS_MHTML_RESPONSE = 104,
BDH_DEVICE_NOT_ALLOWED_FOR_ORIGIN = 105,
OBSOLETE_ACI_WRONG_STORAGE_PARTITION = 106,
OBSOLETE_RDHI_WRONG_STORAGE_PARTITION = 107,
RDH_INVALID_REQUEST_ID = 108,
BDH_SERVICE_NOT_ALLOWED_FOR_ORIGIN = 109,
WSI_UNEXPECTED_ADD_CHANNEL_REQUEST = 110,
WSI_UNEXPECTED_SEND_FRAME = 111,
RFH_UNEXPECTED_LOAD_START = 112,
NMF_INVALID_ARGUMENT = 113,
RFH_INVALID_ORIGIN_ON_COMMIT = 114,
BDH_UUID_REGISTERED = 115,
BDH_CONSTRUCTION_FAILED = 116,
BDH_INVALID_REFCOUNT_OPERATION = 117,
BDH_INVALID_URL_OPERATION = 118,
OBSOLETE_IDBDH_INVALID_ORIGIN = 119,
RFH_FAIL_PROVISIONAL_LOAD_NO_HANDLE = 120,
OBSOLETE_RFH_FAIL_PROVISIONAL_LOAD_NO_ERROR = 121,
NI_IN_PAGE_NAVIGATION = 122,
RPH_MOJO_PROCESS_ERROR = 123,
OBSOLETE_DBMF_INVALID_ORIGIN_ON_GET_SPACE = 124,
OBSOLETE_DBMF_INVALID_ORIGIN_ON_MODIFIED = 125,
OBSOLETE_DBMF_INVALID_ORIGIN_ON_CLOSED = 126,
OBSOLETE_WSI_INVALID_HEADER_VALUE = 127,
OBSOLETE_SWDH_SET_HOSTED_VERSION_INVALID_HOST = 128,
OBSOLETE_SWDH_SET_HOSTED_VERSION_PROCESS_MISMATCH = 129,
OBSOLETE_MSDH_INVALID_FRAME_ID = 130,
SDH_INVALID_PORT_RANGE = 131,
SCO_INVALID_ARGUMENT = 132,
RFH_INCONSISTENT_DEVTOOLS_MESSAGE = 133,
DSH_DUPLICATE_CONNECTION_ID = 134,
DSH_NOT_CREATED_SESSION_ID = 135,
DSH_NOT_ALLOCATED_SESSION_ID = 136,
DSH_DELETED_SESSION_ID = 137,
OBSOLETE_DSH_WRONG_STORAGE_PARTITION = 138,
BDH_DISALLOWED_ORIGIN = 139,
ARH_CREATED_STREAM_WITHOUT_AUTHORIZATION = 140,
MDDH_INVALID_DEVICE_TYPE_REQUEST = 141,
OBSOLETE_MDDH_UNAUTHORIZED_ORIGIN = 142,
OBSOLETE_SWDH_ENABLE_NAVIGATION_PRELOAD_NO_HOST = 143,
OBSOLETE_SWDH_ENABLE_NAVIGATION_PRELOAD_INVALID_ORIGIN = 144,
OBSOLETE_SWDH_ENABLE_NAVIGATION_PRELOAD_BAD_REGISTRATION_ID = 145,
OBSOLETE_RDH_TRANSFERRING_REQUEST_NOT_FOUND =
146, // Disabled - crbug.com/659613.
OBSOLETE_RDH_TRANSFERRING_NONNAVIGATIONAL_REQUEST = 147,
OBSOLETE_SWDH_GET_NAVIGATION_PRELOAD_STATE_NO_HOST = 148,
OBSOLETE_SWDH_GET_NAVIGATION_PRELOAD_STATE_INVALID_ORIGIN = 149,
OBSOLETE_SWDH_GET_NAVIGATION_PRELOAD_STATE_BAD_REGISTRATION_ID = 150,
OBSOLETE_SWDH_SET_NAVIGATION_PRELOAD_HEADER_NO_HOST = 151,
OBSOLETE_SWDH_SET_NAVIGATION_PRELOAD_HEADER_INVALID_ORIGIN = 152,
OBSOLETE_SWDH_SET_NAVIGATION_PRELOAD_HEADER_BAD_REGISTRATION_ID = 153,
OBSOLETE_SWDH_SET_NAVIGATION_PRELOAD_HEADER_BAD_VALUE = 154,
MDDH_INVALID_SUBSCRIPTION_REQUEST = 155,
OBSOLETE_MDDH_INVALID_UNSUBSCRIPTION_REQUEST = 156,
OBSOLETE_AOAH_NONSENSE_DEVICE_ID = 157,
BDH_INVALID_OPTIONS = 158,
RFH_DID_ADD_CONSOLE_MESSAGE_BAD_SEVERITY = 159,
AIRH_VOLUME_OUT_OF_RANGE = 160,
BDH_INVALID_DESCRIPTOR_ID = 161,
OBSOLETE_RWH_INVALID_BEGIN_FRAME_ACK_DID_NOT_SWAP = 162,
OBSOLETE_RWH_INVALID_BEGIN_FRAME_ACK_COMPOSITOR_FRAME = 163,
BFSI_INVALID_DEVELOPER_ID = 164,
BFSI_INVALID_REQUESTS = 165,
BFSI_INVALID_TITLE = 166,
RWH_INVALID_FRAME_TOKEN = 167,
RWH_BAD_FRAME_SINK_REQUEST = 168,
RWH_SURFACE_INVARIANTS_VIOLATION = 169,
ILLEGAL_UPLOAD_PARAMS = 170,
RFH_BASE_URL_FOR_DATA_URL_SPECIFIED = 171,
OBSOLETE_RFPH_ILLEGAL_UPLOAD_PARAMS = 172,
OBSOLETE_SWDH_PROVIDER_CREATED_ILLEGAL_TYPE = 173,
OBSOLETE_SWDH_PROVIDER_CREATED_ILLEGAL_TYPE_NOT_WINDOW = 174,
OBSOLETE_SWDH_PROVIDER_CREATED_ILLEGAL_TYPE_SERVICE_WORKER = 175,
OBSOLETE_SWDH_PROVIDER_CREATED_DUPLICATE_ID = 176,
OBSOLETE_SWDH_PROVIDER_CREATED_BAD_ID = 177,
RFH_KEEP_ALIVE_HANDLE_REQUESTED_INCORRECTLY = 178,
BFSI_INVALID_UNIQUE_ID = 179,
BPE_UNEXPECTED_MESSAGE_BEFORE_BPGM_CREATION = 180,
WEBUI_SEND_FROM_UNAUTHORIZED_PROCESS = 181,
CPFC_RESIZE_PARAMS_CHANGED_LOCAL_SURFACE_ID_UNCHANGED = 182,
BPG_RESIZE_PARAMS_CHANGED_LOCAL_SURFACE_ID_UNCHANGED = 183,
RFH_NEGATIVE_SELECTION_START_OFFSET = 184,
WEBUI_BAD_SCHEME_ACCESS = 185,
CSDH_UNEXPECTED_OPERATION = 186,
RMF_BAD_URL_CACHEABLE_METADATA = 187,
RFH_INTERFACE_PROVIDER_MISSING = 188,
OBSOLETE_RFH_INTERFACE_PROVIDER_SUPERFLUOUS = 189,
AIRH_UNEXPECTED_BITSTREAM = 190,
ARH_UNEXPECTED_BITSTREAM = 191,
RDH_NULL_CLIENT = 192,
RVH_WEB_UI_BINDINGS_MISMATCH = 193,
WCI_NEW_WIDGET_PROCESS_MISMATCH = 194,
AUTH_INVALID_EFFECTIVE_DOMAIN = 195,
AUTH_INVALID_RELYING_PARTY = 196,
RWH_COPY_REQUEST_ATTEMPT = 197,
SYNC_COMPOSITOR_NO_FUTURE_FRAME = 198,
SYNC_COMPOSITOR_NO_BEGIN_FRAME = 199,
WEBUI_BAD_HOST_ACCESS = 200,
OBSOLETE_RFMF_BLOB_URL_TOKEN_FOR_NON_BLOB_URL = 201,
PERMISSION_SERVICE_BAD_PERMISSION_DESCRIPTOR = 202,
BLOB_URL_TOKEN_FOR_NON_BLOB_URL = 203,
OBSOLETE_RFPH_BLOB_URL_TOKEN_FOR_NON_BLOB_URL = 204,
RFH_ERROR_PROCESS_NON_ERROR_COMMIT = 205,
RFH_ERROR_PROCESS_NON_UNIQUE_ORIGIN_COMMIT = 206,
RFH_CANNOT_RENDER_FALLBACK_CONTENT = 207,
RFH_CHILD_FRAME_NEEDS_OWNER_ELEMENT_TYPE = 208,
OBSOLETE_RFH_INVALID_WEB_REPORTING_CRASH_ID = 209,
RFH_DETACH_MAIN_FRAME = 210,
RFH_DOCUMENT_INTERFACE_BROKER_MISSING = 211,
RFPH_POST_MESSAGE_INVALID_SOURCE_ORIGIN = 212,
INVALID_INITIATOR_ORIGIN = 213,
RFHI_BEGIN_NAVIGATION_MISSING_INITIATOR_ORIGIN = 214,
RFHI_BEGIN_NAVIGATION_NON_WEBBY_TRANSITION = 215,
RFH_NO_MATCHING_NAVIGATION_REQUEST_ON_COMMIT = 216,
AUTH_INVALID_ICON_URL = 217,
// Please add new elements here. The naming convention is abbreviated class
// name (e.g. RenderFrameHost becomes RFH) plus a unique description of the
// reason. After making changes, you MUST update histograms.xml by running:
// "python tools/metrics/histograms/update_bad_message_reasons.py"
BAD_MESSAGE_MAX
};
// Called when the browser receives a bad IPC message from a renderer process on
// the UI thread. Logs the event, records a histogram metric for the |reason|,
// and terminates the process for |host|.
void ReceivedBadMessage(RenderProcessHost* host, BadMessageReason reason);
// Equivalent to the above, but callable from any thread.
CONTENT_EXPORT void ReceivedBadMessage(int render_process_id,
BadMessageReason reason);
// Called when a browser message filter receives a bad IPC message from a
// renderer or other child process. Logs the event, records a histogram metric
// for the |reason|, and terminates the process for |filter|.
void ReceivedBadMessage(BrowserMessageFilter* filter, BadMessageReason reason);
// Returns a crash key named "mojo-message-error" for storing Mojo error
// messages.
base::debug::CrashKeyString* GetMojoErrorCrashKey();
// Site isolation. These keys help debug renderer kills such as
// https://crbug.com/773140.
// Returns a key named "killed_process_origin_lock".
base::debug::CrashKeyString* GetKilledProcessOriginLockKey();
// Retuns a key named "requested_site_url".
base::debug::CrashKeyString* GetRequestedSiteURLKey();
} // namespace bad_message
} // namespace content
#endif // CONTENT_BROWSER_BAD_MESSAGE_H_