opt
/
kaspersky
/
kav4fs
/
src
/
kernel
/
module.linux
➕ New
📤 Upload
✎ Editing:
module.c
← Back
/* * This source file is a part of a Kaspersky Antivirus Monitor. * Copyright (C) Kaspersky Lab, 1997-2010 * See License.txt for details * */ #include "module.h" #include "oas/small/protocol_alloc.h" #include <linux/module.h> #include <linux/init.h> struct vfsmount* orig_rootmnt = NULL; struct dentry* orig_root = NULL; /* Module section */ MODULE_AUTHOR("Kaspersky Lab"); MODULE_DESCRIPTION("Kaspersky Anti-Virus Monitor Module for Linux."); #ifdef LINUX_KERNEL26 MODULE_INFO(supported, "external"); extern int use_binfmt; module_param(use_binfmt, int, S_IRUGO); MODULE_PARM_DESC(use_binfmt, "Enables hook on exec system call."); #endif static atomic_t monitor_count; void Monitor_ins_use(void) { #ifdef LINUX_KERNEL26 try_module_get(THIS_MODULE); #else MOD_INC_USE_COUNT; #endif atomic_inc(&monitor_count); } void Monitor_dec_use(void) { #ifdef LINUX_KERNEL26 module_put(THIS_MODULE); #else MOD_DEC_USE_COUNT; #endif atomic_dec(&monitor_count); } int Monitor_busy(void) { return atomic_read(&monitor_count) ? 1 : 0; } #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 48)) int init_module(void) #else static int __init kavmon_init_module(void) #endif { if (current == NULL) { printk("kavmon: panic (current == NULL)\n"); return -1; } task_lock(current); if (current->fs == NULL) { printk("kavmon: panic (current->fs == NULL)\n"); task_unlock(current); return -1; } #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)) if (current->fs->root == NULL) { printk("kavmon: panic (current->fs->root == NULL)\n"); task_unlock(current); return -1; } if (current->fs->rootmnt == NULL) { printk("kavmon: panic (current->fs->rootmnt == NULL)\n"); task_unlock(current); return -1; } #else if (current->fs->root.dentry == NULL) { printk("kavmon: panic (current->fs->root == NULL)\n"); task_unlock(current); return -1; } if (current->fs->root.mnt == NULL) { printk("kavmon: panic (current->fs->rootmnt == NULL)\n"); task_unlock(current); return -1; } #endif get_current_fs_root(&orig_rootmnt, &orig_root); task_unlock(current); atomic_xchg(&monitor_count, 0); return Monitor_interface_init(); } #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 48)) void cleanup_module(void) #else static void __exit kavmon_cleanup_module(void) #endif { Monitor_interface_cleanup(); dput(orig_root); mntput(orig_rootmnt); } #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 3, 48)) module_init(kavmon_init_module); module_exit(kavmon_cleanup_module); #ifdef MODULE_LICENSE MODULE_LICENSE("GPL"); #endif #endif
💾 Save Changes
Cancel
📤 Upload File
×
Select File
Upload
Cancel
➕ Create New
×
Type
📄 File
📁 Folder
Name
Create
Cancel
✎ Rename Item
×
Current Name
New Name
Rename
Cancel
🔐 Change Permissions
×
Target File
Permission (e.g., 0755, 0644)
0755
0644
0777
Apply
Cancel