RLBox
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
rlbox::rlbox_sandbox< T_Sbx > Class Template Reference

Encapsulation for sandboxes. More...

#include <rlbox_sandbox.hpp>

Inheritance diagram for rlbox::rlbox_sandbox< T_Sbx >:
Inheritance graph
[legend]
Collaboration diagram for rlbox::rlbox_sandbox< T_Sbx >:
Collaboration graph
[legend]

Public Types

template<typename T >
using convert_to_sandbox_equivalent_nonclass_t = detail::convert_base_types_t< T, typename T_Sbx::T_ShortType, typename T_Sbx::T_IntType, typename T_Sbx::T_LongType, typename T_Sbx::T_LongLongType, typename T_Sbx::T_PointerType >
 
template<typename T_Ret , typename... T_Args>
using T_Cb_no_wrap = detail::rlbox_remove_wrapper_t< T_Ret >(detail::rlbox_remove_wrapper_t< T_Args >...)
 

Public Member Functions

T_Sbx * get_sandbox_impl ()
 
template<typename... T_Args>
auto create_sandbox (T_Args... args)
 Create a new sandbox. More...
 
auto destroy_sandbox ()
 Destroy sandbox and reclaim any memory.
 
template<typename T >
get_unsandboxed_pointer (convert_to_sandbox_equivalent_nonclass_t< T > p) const
 
template<typename T >
convert_to_sandbox_equivalent_nonclass_t< T > get_sandboxed_pointer (const void *p) const
 
template<typename T >
tainted< T *, T_Sbx > malloc_in_sandbox ()
 Allocate a new pointer that is accessible to both the application and sandbox. The pointer is allocated in sandbox memory. More...
 
template<typename T >
tainted< T *, T_Sbx > malloc_in_sandbox (uint32_t count)
 Allocate an array that is accessible to both the application and sandbox. The pointer is allocated in sandbox memory. More...
 
template<typename T >
void free_in_sandbox (tainted< T *, T_Sbx > ptr)
 Free the memory referenced by the tainted pointer. More...
 
template<typename T >
void free_in_sandbox (tainted_volatile< T, T_Sbx > &ptr_ref)
 Free the memory referenced by a tainted_volatile pointer ref. More...
 
template<typename T >
void free_in_sandbox (tainted_opaque< T, T_Sbx > ptr_opaque)
 Free the memory referenced by a tainted_opaque pointer. More...
 
bool is_pointer_in_sandbox_memory (const void *p)
 Check if the pointer points to this sandbox's memory. For the null-sandbox, this always returns true.
 
bool is_pointer_in_app_memory (const void *p)
 Check if the pointer points to application memory. For the null-sandbox, this always returns true.
 
size_t get_total_memory ()
 
void * get_memory_location ()
 
void * get_transition_state ()
 
void set_transition_state (void *new_state)
 
template<typename T >
tainted< T *, T_Sbx > INTERNAL_grant_access (T *src, size_t num, bool &success)
 For internal use only. Grant access of the passed in buffer in to the sandbox instance. Called by internal APIs only if the underlying sandbox supports can_grant_deny_access by including the line. More...
 
template<typename T >
T * INTERNAL_deny_access (tainted< T *, T_Sbx > src, size_t num, bool &success)
 For internal use only. Grant access of the passed in buffer in to the sandbox instance. Called by internal APIs only if the underlying sandbox supports can_grant_deny_access by including the line. More...
 
void * lookup_symbol (const char *func_name)
 
template<typename T , typename... T_Args>
auto INTERNAL_invoke_with_func_name (const char *func_name, T_Args &&... params)
 
template<typename T , typename... T_Args>
auto INTERNAL_invoke_with_func_ptr (const char *func_name, void *func_ptr, T_Args &&... params)
 
template<typename T2 >
tainted< T2, T_Sbx > UNSAFE_accept_pointer (T2 ptr)
 
template<typename T_Ret >
sandbox_callback< T_Cb_no_wrap< T_Ret > *, T_Sbx > register_callback (T_Ret(*)())
 
template<typename T_RL , typename T_Ret , typename... T_Args>
sandbox_callback< T_Cb_no_wrap< T_Ret, T_Args... > *, T_Sbx > register_callback (T_Ret(*func_ptr)(T_RL, T_Args...))
 Expose a callback function to the sandboxed code. More...
 
template<typename T >
tainted< T *, T_Sbx > INTERNAL_get_sandbox_function_name (const char *func_name)
 
template<typename T >
tainted< T *, T_Sbx > INTERNAL_get_sandbox_function_ptr (void *func_ptr)
 
template<typename T >
app_pointer< T *, T_Sbx > get_app_pointer (T *ptr)
 Create a "fake" pointer referring to a location in the application memory. More...
 
template<typename T >
T * lookup_app_ptr (tainted< T *, T_Sbx > tainted_ptr)
 The mirror of get_app_pointer. Take a tainted pointer which is actually an app_pointer, and get the application location being pointed to. More...
 

Static Public Member Functions

template<typename T >
static T get_unsandboxed_pointer_no_ctx (convert_to_sandbox_equivalent_nonclass_t< T > p, const void *example_unsandboxed_ptr)
 
template<typename T >
static convert_to_sandbox_equivalent_nonclass_t< T > get_sandboxed_pointer_no_ctx (const void *p, const void *example_unsandboxed_ptr)
 
static bool is_in_same_sandbox (const void *p1, const void *p2)
 Check if two pointers are in the same sandbox. For the null-sandbox, this always returns true.
 

Public Attributes

void * sandbox_storage
 Unused member that allows the calling code to save data in a "per-sandbox" storage. This can be useful to save context which is used in callbacks.
 

Detailed Description

template<typename T_Sbx>
class rlbox::rlbox_sandbox< T_Sbx >

Encapsulation for sandboxes.

Template Parameters
T_SbxType of sandbox. For the null sandbox this is rlbox_noop_sandbox

Member Function Documentation

◆ create_sandbox()

template<typename T_Sbx >
template<typename... T_Args>
auto rlbox::rlbox_sandbox< T_Sbx >::create_sandbox ( T_Args...  args)
inline

Create a new sandbox.

Template Parameters
T_argsArguments passed to the underlying sandbox implementation. For the null sandbox, no arguments are necessary.

◆ free_in_sandbox() [1/3]

template<typename T_Sbx >
template<typename T >
void rlbox::rlbox_sandbox< T_Sbx >::free_in_sandbox ( tainted< T *, T_Sbx >  ptr)
inline

Free the memory referenced by the tainted pointer.

Parameters
ptrPointer to sandbox memory to free.

◆ free_in_sandbox() [2/3]

template<typename T_Sbx >
template<typename T >
void rlbox::rlbox_sandbox< T_Sbx >::free_in_sandbox ( tainted_opaque< T, T_Sbx >  ptr_opaque)
inline

Free the memory referenced by a tainted_opaque pointer.

Parameters
ptr_opaqueOpaque pointer to sandbox memory to free.

◆ free_in_sandbox() [3/3]

template<typename T_Sbx >
template<typename T >
void rlbox::rlbox_sandbox< T_Sbx >::free_in_sandbox ( tainted_volatile< T, T_Sbx > &  ptr_ref)
inline

Free the memory referenced by a tainted_volatile pointer ref.

Parameters
ptr_refPointer reference to sandbox memory to free.

◆ get_app_pointer()

template<typename T_Sbx >
template<typename T >
app_pointer<T*, T_Sbx> rlbox::rlbox_sandbox< T_Sbx >::get_app_pointer ( T *  ptr)
inline

Create a "fake" pointer referring to a location in the application memory.

Parameters
ptrThe pointer to refer to
Returns
The app_pointer object that refers to this location.

◆ INTERNAL_deny_access()

template<typename T_Sbx >
template<typename T >
T* rlbox::rlbox_sandbox< T_Sbx >::INTERNAL_deny_access ( tainted< T *, T_Sbx >  src,
size_t  num,
bool &  success 
)
inline

For internal use only. Grant access of the passed in buffer in to the sandbox instance. Called by internal APIs only if the underlying sandbox supports can_grant_deny_access by including the line.

using can_grant_deny_access = void;

◆ INTERNAL_grant_access()

template<typename T_Sbx >
template<typename T >
tainted<T*, T_Sbx> rlbox::rlbox_sandbox< T_Sbx >::INTERNAL_grant_access ( T *  src,
size_t  num,
bool &  success 
)
inline

For internal use only. Grant access of the passed in buffer in to the sandbox instance. Called by internal APIs only if the underlying sandbox supports can_grant_deny_access by including the line.

using can_grant_deny_access = void;

◆ lookup_app_ptr()

template<typename T_Sbx >
template<typename T >
T* rlbox::rlbox_sandbox< T_Sbx >::lookup_app_ptr ( tainted< T *, T_Sbx >  tainted_ptr)
inline

The mirror of get_app_pointer. Take a tainted pointer which is actually an app_pointer, and get the application location being pointed to.

Parameters
tainted_ptrThe tainted pointer that is actually an app_pointer
Returns
The original location being referred to by the app_ptr

◆ malloc_in_sandbox() [1/2]

template<typename T_Sbx >
template<typename T >
tainted<T*, T_Sbx> rlbox::rlbox_sandbox< T_Sbx >::malloc_in_sandbox ( )
inline

Allocate a new pointer that is accessible to both the application and sandbox. The pointer is allocated in sandbox memory.

Template Parameters
TThe type of the pointer you want to create. If T=int, this would return a pointer to an int.
Returns
tainted<T*, T_Sbx> Tainted pointer accessible to the application and sandbox.

◆ malloc_in_sandbox() [2/2]

template<typename T_Sbx >
template<typename T >
tainted<T*, T_Sbx> rlbox::rlbox_sandbox< T_Sbx >::malloc_in_sandbox ( uint32_t  count)
inline

Allocate an array that is accessible to both the application and sandbox. The pointer is allocated in sandbox memory.

Template Parameters
TThe type of the array elements you want to create. If T=int, this would return a pointer to an array of ints.
Parameters
countThe number of array elements to allocate.
Returns
tainted<T*, T_Sbx> Tainted pointer accessible to the application and sandbox.

◆ register_callback()

template<typename T_Sbx >
template<typename T_RL , typename T_Ret , typename... T_Args>
sandbox_callback<T_Cb_no_wrap<T_Ret, T_Args...>*, T_Sbx> rlbox::rlbox_sandbox< T_Sbx >::register_callback ( T_Ret(*)(T_RL, T_Args...)  func_ptr)
inline

Expose a callback function to the sandboxed code.

Parameters
func_ptrThe callback to expose.
Template Parameters
T_RLSandbox reference type (first argument).
T_RetReturn type of callback. Must be tainted or void.
T_ArgsTypes of remaining callback arguments. Must be tainted.
Returns
Wrapped callback function pointer that can be passed to the sandbox.

The documentation for this class was generated from the following file: