linux模块的卸载

Unloading a Module

Modules can be removed using the rmmod command but demand loaded modules are automatically removed from the system by kerneld when they are no longer being used. Every time its idle timer expires, kerneld makes a system call requesting that all unused demand loaded modules are removed from the system. The timer's value is set when you start kerneld; my kerneld checks every 180 seconds. So, for example, if you mount an iso9660 CD ROM and your iso9660 filesystem is a loadable module, then shortly after the CD ROM is unmounted, the iso9660 module will be removed from the kernel.

A module cannot be unloaded so long as other components of the kernel are depending on it.For example, you cannot unload the VFAT module if you have one or more VFAT file systems mounted. If you look at the output of lsmod, you will see that each module has a count associated with it. For example:

Module:        #pages:  Used by:
msdos              5                  1
vfat               4                  1 (autoclean)
fat                6    [vfat msdos]  2 (autoclean)

The count is the number of kernel entities that are dependent on this module. In the above example, the vfat and msdos modules are both dependent on the fat module and so it has a count of 2. Both the vfat and msdos modules have 1 dependent, which is a mounted file system. If I were to load another VFAT file system then the vfat module's count would become 2. A module's count is held in the first longword of its image.

This field is slightly overloaded as it also holds the AUTOCLEAN and VISITED flags. Both of these flags are used for demand loaded modules. These modules are marked as AUTOCLEAN so that the system can recognize which ones it may automatically unload. The VISITED flag marks the module as in use by one or more other system components; it is set whenever another component makes use of the module. Each time the system is asked by kerneld to remove unused demand loaded modules it looks through all of the modules in the system for likely candidates. It only looks at modules marked as AUTOCLEAN and in the state RUNNING. If the candidate has its VISITED flag cleared then it will remove the module, otherwise it will clear the VISITED flag and go on to look at the next module in the system.

Assuming that a module can be unloaded, its cleanup routine is called to allow it to free up the kernel resources that it has allocated.

The module data structure is marked as DELETED and it is unlinked from the list of kernel modules. Any other modules that it is dependent on have their reference lists modified so that they no longer have it as a dependent. All of the kernel memory that the module needed is deallocated.

第一部分 基础知识 <br>1.1 什么是LKMs <br>1.2 什么是系统调用 <br>1.3 什么是内核符号表(Kernel-Symbol-Table) <br>1.4 如何实现从用户空间到内核空间的转换 <br>1.5 使用用户空间函数的方法 <br>1.6 常用内核空间函数列表 <br>1.7 什么是内核守护进程 <br>1.8 创建你自己的设备 <br><br>第二部分 渐入佳境 <br>2.1 如何截获系统调用 <br>2.2 一些有趣的系统调用 <br>2.2.1 发现有趣的系统调用(strace方法) <br>2.3 迷惑内核的系统表 <br>2.4 和文件系统有关的攻击 <br>2.4.1 如何隐藏文件 <br>2.4.2 如何隐藏文件的内容(完全的) <br>2.4.3 如何隐藏文件的某一部分(一个实现原型) <br>2.4.4 如何重新定向或者监视文件操作 <br>2.4.5 如何避免任何文件权限问题 <br>2.4.6 如何使的一个有入侵工具的目录不可存取 <br>2.4.7 如何改变CHROOT环境 <br>2.5 和进程有关的入侵 <br>2.5.1 如何隐藏任何进程 <br>2.5.2 如果改变文件的执行结果 <br>2.6 和网络(Socket)有关的入侵 <br>2.6.1 如果控制Socket操作 <br>2.7 TTY纪录的方法 <br>2.8 用LKMs写病毒 <br>2.8.1 如何让LKM病毒感染任何文件(不仅仅是模块) <br>2.8.2 如何让LKM病毒帮助我们进入系统 <br>2.9 使我们的LKM不可见,而且不可卸载 <br>2.10 其他的入侵kerneld进程的方法 <br>2.11 如何检查当前的我们的LKM <br><br>第三部分 解决方案(给系统管理员) <br>3.1 LKM检测的理论和想法 <br>3.1.1 一个使用的检测器的原形 <br>3.1.2 一个密码保护的create_module(...)的例子 <br>3.2 防止LKM传染者的方法 <br>3.3 使你的程序不可以被跟踪(理论) <br>3.3.1 一个反跟踪的实用例子 <br>3.4 使用LKMs来防护你的linux内核 <br>3.4.1 为什么我们必须允许任何一个程序都拥有可执行的权限 <br>3.4.2 链接的补丁 <br>3.4.3 /proc权限的补丁 <br>3.4.4 安全级别的补丁 <br>3.4.5 底层磁盘补丁 <br><br>第四部分 一些更好的想法(给hacker的) <br>4.1 击败系统管理员的LKM的方法 <br>4.2 修补整个内核-或者创建Hacker-OS <br>4.2.1 如何在/dev/kmem中找到内核符号表 <br>4.2.2 新的不需要内核支持的'insmod' <br>4.3 最后的话 <br><br>第五部分 最近的一些东西:2.2.x版本的内核 <br>5.1 对于LKM作者来说,一些主要的不同点 <br><br>第六部分 最后的话 <br>6.1 LKM传奇以及如何使得一个系统即好用又安全 <br>6.2 一些资源链接
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值