/**
@file
@brief Linux kernel 'module'
@details Copyright (c) 2017 Acronis International GmbH
@author Mikhail Krivtsov (mikhail.krivtsov@acronis.com)
@since $Id: $
*/
#include "debug.h" // DPRINTF
#include "file_contexts.h"
#include "module_rundown_protection.h"
#include "syscall_common.h"
#include "task_info_map.h"
#include "tracepoints.h"
#include "transport.h"
#include <linux/rcupdate.h>
#include <linux/module.h>
#include <linux/version.h> // LINUX_VERSION_CODE, KERNEL_VERSION()
#ifdef __DEBUG_LEVEL__
#ifdef DEFAULT_LOGGER_DEBUG_LEVEL
unsigned int logger_debug_level = DEFAULT_LOGGER_DEBUG_LEVEL;
#else
unsigned int logger_debug_level = 0;
#endif
#endif
/*
Initialization order is very important.
'transport' depends on 'pid_bw_list'
'syscall_hooks' and 'tracepoints' depend on 'transport'
*/
static int __init module_init_impl(void)
{
int ret;
IPRINTF("DRIVER_VERSION=%s", DRIVER_VERSION_STRING);
IPRINTF("LINUX_VERSION_CODE=%u.%u.%u", LINUX_VERSION_CODE >> 16,
(LINUX_VERSION_CODE >> 8) & 0xFF, LINUX_VERSION_CODE & 0xFF);
#if defined RHEL_RELEASE_CODE
IPRINTF("RHEL_RELEASE_CODE=%u.%u",
RHEL_RELEASE_CODE >> 8, RHEL_RELEASE_CODE & 0xFF);
#endif
compat_init();
task_info_maps_init();
file_contexts_init();
mod_rundown_protection_init(false /*not ready*/);
ret = transport_mod_init();
if (ret) {
EPRINTF("'%s()' failure %i", "transport_mod_init", ret);
}
DPRINTF("ret=%i", ret);
return ret;
}
static void __exit module_down_impl(void)
{
IPRINTF("module unload started");
transport_mod_down();
task_info_maps_clear();
file_contexts_deinit();
synchronize_rcu();
rcu_barrier();
IPRINTF("module unload finished");
}
MODULE_AUTHOR("Acronis International GmbH");
MODULE_DESCRIPTION("APL (Active Protection for Linux)");
MODULE_LICENSE("GPL");
MODULE_VERSION(DRIVER_VERSION_STRING);
module_init(module_init_impl);
module_exit(module_down_impl);
|