static int remove_os_hooks(void)
{
	void *orgFn;

	/* only remove the os hooks when install_os_hooks() has been called */
	if (!gb_enable_os_hooks)
		return 0;

	if ((orgFn = xchg(&px_original_sys_fork, 0)))
		orgFn = xchg(&system_call_table[__NR_fork - __NR_SYSCALL_BASE], orgFn);

	if ((orgFn = xchg(&px_original_sys_vfork, 0)))
		orgFn = xchg(&system_call_table[__NR_vfork - __NR_SYSCALL_BASE], orgFn);

	if ((orgFn = xchg(&px_original_sys_clone, 0)))
		orgFn = xchg(&system_call_table[__NR_clone - __NR_SYSCALL_BASE], orgFn);

	if ((orgFn = xchg(&px_original_sys_execve, 0)))
		orgFn = xchg(&system_call_table[__NR_execve - __NR_SYSCALL_BASE], orgFn);

	if ((orgFn = xchg(&px_original_sys_mmap, 0)))
		orgFn = xchg(&system_call_table[__NR_mmap - __NR_SYSCALL_BASE], orgFn);

	if ((orgFn = xchg(&px_original_sys_mmap2, 0)))
		orgFn = xchg(&system_call_table[__NR_mmap2 - __NR_SYSCALL_BASE], orgFn);

	if ((orgFn = xchg(&px_original_sys_exit, 0)))
		orgFn = xchg(&system_call_table[__NR_exit - __NR_SYSCALL_BASE], orgFn);

	if ((orgFn = xchg(&px_original_sys_exit_group, 0)))
		orgFn = xchg(&system_call_table[__NR_exit_group - __NR_SYSCALL_BASE], orgFn);

	if ((orgFn = xchg(&px_original_sys_kill, 0)))
		orgFn = xchg(&system_call_table[__NR_kill - __NR_SYSCALL_BASE], orgFn);

	if ((orgFn = xchg(&px_original_sys_tkill, 0)))
		orgFn = xchg(&system_call_table[__NR_tkill - __NR_SYSCALL_BASE], orgFn);

	if ((orgFn = xchg(&px_original_sys_tgkill, 0)))
		orgFn = xchg(&system_call_table[__NR_tgkill - __NR_SYSCALL_BASE], orgFn);

	if ((orgFn = xchg(&px_original_sys_prctl, 0)))
		orgFn = xchg(&system_call_table[__NR_prctl - __NR_SYSCALL_BASE], orgFn);

#ifdef CONFIG_PROFILING
	// unregister task exit notifier
	profile_event_unregister(PROFILE_TASK_EXIT, &task_exit_nb);
#endif

	// unregister module state change notifier
	unregister_module_notifier(&nb_init);

	gb_enable_os_hooks = false;

	return 0;
}
Exemplo n.º 2
0
void
kedr_target_detector_destroy(void)
{
	unregister_module_notifier(&detector_nb);

	if(target_module)
	{
		pr_warning(COMPONENT_STRING
"Target module detector was unloaded while target module is loaded.");
	}
	
	kfree(target_name);
}
static int remove_os_hooks(void)
{
	void *orgFn;

	/* only remove the os hooks when install_os_hooks() has been called */
	if (!gb_enable_os_hooks)
		return 0;
	
	if ((orgFn = xchg(&px_original_sys_fork, 0)))
		orgFn = xchg(&system_call_table[__NR_fork - __NR_SYSCALL_BASE], orgFn);

	if ((orgFn = xchg(&px_original_sys_vfork, 0)))
		orgFn = xchg(&system_call_table[__NR_vfork - __NR_SYSCALL_BASE], orgFn);
	
	if ((orgFn = xchg(&px_original_sys_clone, 0)))
		orgFn = xchg(&system_call_table[__NR_clone - __NR_SYSCALL_BASE], orgFn);

	if ((orgFn = xchg(&px_original_sys_execve, 0)))
		orgFn = xchg(&system_call_table[__NR_execve - __NR_SYSCALL_BASE], orgFn);

	if ((orgFn = xchg(&px_original_sys_mmap, 0)))
		orgFn = xchg(&system_call_table[__NR_mmap - __NR_SYSCALL_BASE], orgFn);

	if ((orgFn = xchg(&px_original_sys_mmap2, 0)))
		orgFn = xchg(&system_call_table[__NR_mmap2 - __NR_SYSCALL_BASE], orgFn);

	if ((orgFn = xchg(&px_original_sys_exit, 0)))
		orgFn = xchg(&system_call_table[__NR_exit - __NR_SYSCALL_BASE], orgFn);

	if ((orgFn = xchg(&px_original_sys_exit_group, 0)))
		orgFn = xchg(&system_call_table[__NR_exit_group - __NR_SYSCALL_BASE], orgFn);

	if ((orgFn = xchg(&px_original_sys_kill, 0)))
		orgFn = xchg(&system_call_table[__NR_kill - __NR_SYSCALL_BASE], orgFn);
		
	if ((orgFn = xchg(&px_original_sys_tkill, 0)))
		orgFn = xchg(&system_call_table[__NR_tkill - __NR_SYSCALL_BASE], orgFn);

	if ((orgFn = xchg(&px_original_sys_tgkill, 0)))
		orgFn = xchg(&system_call_table[__NR_tgkill - __NR_SYSCALL_BASE], orgFn);

	// unregister module state change notifier
	unregister_module_notifier(&nb_init);
	
	gb_enable_os_hooks = false;
	
	return 0;
}
Exemplo n.º 4
0
/* ================================================================ */
static void
controller_cleanup_module(void)
{
    int i; //for iterate payloads

	unregister_module_notifier(&detector_nb);
	kedr_impl_controller_unregister(&controller);

	for(i = 0; i < payloads_n; i++) payloads_exit[i]();
    
    base_exit_module();

/* TODO later: uninstrument target if it is still loaded.
 * This makes sense only if there is a reasonable safe way of instrumenting
 * a live module ("hot patching") available.
 */
	KEDR_MSG(COMPONENT_STRING 
		"cleanup successful\n");
	return;
}
Exemplo n.º 5
0
static int unprobe_kmodules(void)
{
    return unregister_module_notifier(&vtss_kmodules_nb);
}
Exemplo n.º 6
0
/* when someone does /sbin/rmmod on a loaded systemtap module. */
static void _stp_cleanup_and_exit(int send_exit)
{
	int handle_exit;
	int start_finished;

	mutex_lock(&_stp_transport_mutex);
	handle_exit = (_stp_start_called && ! _stp_exit_called);
	_stp_exit_called = 1;
	mutex_unlock(&_stp_transport_mutex);

	/* Note, we can be sure that the startup sequence has finished
           if handle_exit is true because it depends on _stp_start_called
	   being set to true. _stp_start_called can only be set to true
	   in _stp_handle_start() in response to a _STP_START message on
	   the control channel. Only one writer can have the control
	   channel open at a time, so the whole startup sequence in
	   _stp_handle_start() has to be completed before another message
	   can be send.  _stp_cleanup_and_exit() can only be called through
	   either a _STP_EXIT message, which cannot arrive while _STP_START
	   is still being handled, or when the module is unloaded. The
	   module can only be unloaded when there are no more users that
	   keep the control channel open.  */
	if (handle_exit) {
		int failures;

	        /* Unregister the module notifier. */
	        if (_stp_module_notifier_active) {
	                _stp_module_notifier_active = 0;
	                (void) unregister_module_notifier(& _stp_module_notifier_nb);
	                /* -ENOENT is possible, if we were not already registered */
	        }

                dbug_trans(1, "cleanup_and_exit (%d)\n", send_exit);
		_stp_exit_flag = 1;

		if (_stp_probes_started) {
			dbug_trans(1, "calling systemtap_module_exit\n");
			/* tell the stap-generated code to unload its probes, etc */
			systemtap_module_exit();
			dbug_trans(1, "done with systemtap_module_exit\n");
		}

		failures = atomic_read(&_stp_transport_failures);
		if (failures)
			_stp_warn("There were %d transport failures.\n", failures);

		dbug_trans(1, "*** calling _stp_transport_data_fs_stop ***\n");
		_stp_transport_data_fs_stop();

		dbug_trans(1, "ctl_send STP_EXIT\n");
		if (send_exit) {
			/* send_exit is only set to one if called from
			   _stp_ctl_write_cmd() in response to a write
			   to the proc cmd file, so in user context. It
			   is safe to immediately notify the reader.  */
			_stp_ctl_send_notify(STP_EXIT, NULL, 0);
		}
		dbug_trans(1, "done with ctl_send STP_EXIT\n");

		/* Unregister the panic notifier. */
#if STP_TRANSPORT_VERSION == 2
		atomic_notifier_chain_unregister(&panic_notifier_list, &_stp_module_panic_notifier_nb);
#endif
	}
}
Exemplo n.º 7
0
/*
 * strom_cleanup_extra_symbols - release modules where the extra symbol
 * points to, and unregister the notifier.
 */
static void __exit
strom_exit_extra_symbols(void)
{
	unregister_module_notifier(&nvme_strom_nb);
	strom_put_all_extra_modules();
}
Exemplo n.º 8
0
void enable_module_loading ( void )
{
    unregister_module_notifier(&nb);
}