shell bypass 403
/** @file @brief kernel/userspace transport messages @details Copyright (c) 2017-2020 Acronis International GmbH @author Mikhail Krivtsov ([email protected]) @since $Id: $ */ #pragma once #include "file_contexts.h" #include "si_common.h" #include "subtype.h" #include "thread_safe_path.h" #include "task_info_map.h" #include "transport.h" #include "transport_protocol.h" #include <linux/atomic.h> #include <linux/list.h> #include <linux/types.h> // bool, size_t, [u]int(8|16|32|64)_t #include <linux/wait.h> // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // 'msg_img_t' accessors #define IMG_ID(msg_img) *(&(msg_img)->id) #define IMG_REPLY(msg_img) *(&(msg_img)->reply) #define IMG_TYPE(msg_img) *(&(msg_img)->type) #define IMG_PAYLOAD(msg_img) (void *) (msg_img)->payload // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - typedef struct msg_s msg_t; struct msg_s { atomic_t ref_cnt; atomic_t reply_wait_count; // number of expected replies wait_queue_head_t wait_queue; // to wait for 'reply' bool interrupted; bool block; // Can be 0, this means event does not require subtype filtering SUBTYPE_MASK_TYPE subtype_mask; thread_safe_path_t path; thread_safe_path_t path2; // This member store the additional necessary information for file context cache task_info_t *task_info; file_context_msg_info_t file_context_msg_info; union { struct { uint64_t pid_version; } exec; struct { uint64_t pid_version; } fork; struct { uint64_t pid_version; int flags; } open; struct { uint64_t pid_version; int flags; uint64_t low; uint64_t high; } write; }; uint64_t id; size_t msg_size; SiEvent event; }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // 'msg_t' accessors #define MSG_IMG(msg) ((request_msg_img_t*) (msg)->img) #define MSG_SIZE(msg) (msg)->img_size #define MSG_ID(msg) IMG_ID(MSG_IMG(msg)) #define MSG_REPLY(msg) IMG_REPLY(MSG_IMG(msg)) #define MSG_TYPE(msg) IMG_TYPE(MSG_IMG(msg)) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - typedef struct msg_sized_s msg_sized_t; struct msg_sized_s { size_t img_size; uint8_t img[]; // 'request_msg_img_t' }; // This should fit most of the messages other than the path ones #define MSG_MAX_SMALL_PAYLOAD_SIZE (8 + sizeof(request_msg_img_t)) // Holds the varsized message either on stack or on heap based on the size. typedef struct msg_varsized_s msg_varsized_t; struct msg_varsized_s { bool on_heap; union { struct { msg_sized_t header; // header.img == img uint8_t img[MSG_MAX_SMALL_PAYLOAD_SIZE]; } stack; struct { msg_sized_t* ptr; } heap; } data; }; const char* msg_type_to_string(msg_type_t type); const char* action_type_to_string(action_type_t type); const char* return_type_to_string(return_type_t type); msg_sized_t *msg_sized_new(size_t msg_img_size); #define msg_sized_free mem_free msg_t *msg_new(uint16_t operation, SUBTYPE_MASK_TYPE subtype_mask, uint16_t callback_type, uint64_t process_uid, size_t props_size); msg_t *msg_new_with_alloc_flags(uint16_t operation, SUBTYPE_MASK_TYPE subtype_mask, uint16_t callback_type, uint64_t process_uid, size_t props_size, bool nowait); msg_t *msg_ref(msg_t *msg); void msg_unref(msg_t *msg); msg_t *msg_reply_wait_count_inc(msg_t *msg); void msg_reply_wait_count_dec(msg_t *msg); msg_t *hello_msg_new(void); msg_t *pong_msg_new(msg_sized_t *ping_msg, uint64_t event_uid); int open_file_return_msg_new(msg_varsized_t *msg, int fd); int version_info_return_msg_new(msg_varsized_t *msg); int data_queue_offsets_return_msg_new(msg_varsized_t *msg, uint32_t size); msg_t *heur_exec_msg_new(task_info_t *task_info, const transport_ids_t *ids); int process_info_return_msg_new(msg_varsized_t *msg, pid_t nr); int process_pid_version_return_msg_new(msg_varsized_t *msg, pid_t nr); #define MSG_VARSIZED_GET_SIZED(msg) ((msg)->on_heap ? (msg)->data.heap.ptr : &(msg)->data.stack.header) msg_sized_t* msg_varsized_init(msg_varsized_t *msg, size_t msg_img_size); void msg_varsized_uninit(msg_varsized_t *msg);