v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
hardware-support.h
Go to the documentation of this file.
1
// Copyright 2024 the V8 project authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#ifndef V8_SANDBOX_HARDWARE_SUPPORT_H_
6
#define V8_SANDBOX_HARDWARE_SUPPORT_H_
7
8
#include "
include/v8-platform.h
"
9
#include "
src/common/globals.h
"
10
11
namespace
v8
{
12
namespace
internal
{
13
14
class
V8_EXPORT_PRIVATE
SandboxHardwareSupport
{
15
public
:
16
// Allocates a pkey that will be used to optionally block sandbox access. This
17
// function should be called once before any threads are created so that new
18
// threads inherit access to the new pkey.
19
static
void
InitializeBeforeThreadCreation();
20
21
// Try to set up hardware permissions to the sandbox address space. If
22
// successful, future calls to MaybeBlockAccess will block the current thread
23
// from accessing the memory.
24
static
bool
TryEnable(Address addr,
size_t
size);
25
26
class
V8_NODISCARD
V8_ALLOW_UNUSED
BlockAccessScope
{
27
public
:
28
#if V8_ENABLE_SANDBOX_HARDWARE_SUPPORT
29
explicit
BlockAccessScope
(
int
pkey);
30
~BlockAccessScope
();
31
32
private
:
33
int
pkey_;
34
#else
35
BlockAccessScope
() =
default
;
36
#endif
37
};
38
39
// If V8_ENABLE_SANDBOX_HARDWARE_SUPPORT is enabled, this function will
40
// prevent any access (read or write) to all sandbox memory on the current
41
// thread, as long as the returned Scope object is valid. The only exception
42
// are read-only pages, which will still be readable.
43
static
BlockAccessScope
MaybeBlockAccess();
44
45
// Removes the pkey from read only pages, so that MaybeBlockAccess will still
46
// allow read access.
47
static
void
NotifyReadOnlyPageCreated(
48
Address addr,
size_t
size,
PageAllocator::Permission
current_permissions);
49
50
// This function should only be called by
51
// `ThreadIsolatedAllocator::SetDefaultPermissionsForSignalHandler`.
52
static
void
SetDefaultPermissionsForSignalHandler();
53
54
private
:
55
#if V8_ENABLE_SANDBOX_HARDWARE_SUPPORT
56
static
int
pkey_;
57
#endif
58
};
59
60
}
// namespace internal
61
}
// namespace v8
62
63
#endif
// V8_SANDBOX_HARDWARE_SUPPORT_H_
v8::PageAllocator::Permission
Permission
Definition
v8-platform.h:486
v8::internal::SandboxHardwareSupport::BlockAccessScope
Definition
hardware-support.h:26
v8::internal::SandboxHardwareSupport::BlockAccessScope::BlockAccessScope
BlockAccessScope()=default
v8::internal::SandboxHardwareSupport
Definition
hardware-support.h:14
globals.h
v8::internal::internal
internal
Definition
wasm-objects-inl.h:458
v8
Definition
api-arguments-inl.h:19
V8_ALLOW_UNUSED
#define V8_ALLOW_UNUSED
Definition
compiler-specific.h:18
V8_EXPORT_PRIVATE
#define V8_EXPORT_PRIVATE
Definition
macros.h:460
v8-platform.h
V8_NODISCARD
#define V8_NODISCARD
Definition
v8config.h:693
src
sandbox
hardware-support.h
Generated on Sun Apr 6 2025 21:08:57 for v8 by
1.12.0