How to disable rmmod for my own written kernel module?

让人想犯罪 __ 提交于 2019-12-11 04:59:58

问题


If a user process is working with kernel module, I want that another process can't fire rmmod for that module. How to achieve this type of functionality?

-beginner in Linux kernel programming.


回答1:


rmmod can only unload a module when the refcount is zero.

If the reference count is incremented when a user process is connected (and decremented when it disconnects), you'll be fine.

If the module exposes a device, or is mounted as a filesystem, this should be handled naturally - if not, I guess it'll depend on the userspace interface, but this where to start looking.

By the way, lsmod will show your module refcount. You can check whether it's incremented when the userspace process connects.



来源:https://stackoverflow.com/questions/9291314/how-to-disable-rmmod-for-my-own-written-kernel-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!