LSM 코딩 중에 문제점이 있어서 질문 해봅니다 @_@
#include
#include
#include
#include
#include
#define MY_NAME "LSM_TEST"
static struct security_operations *original_ops = NULL;
static struct security_operations *secondary_ops = NULL;
static int secondary;
static int rootplug_task_setuid (uid_t id0, uid_t id1, uid_t id2, int flags)
{
printk("%d %d %d %d\n",id0,id1,id2,flags);
return 0;
}
int t_register_security (const char *name, struct security_operations *ops)
{
if (secondary_ops != original_ops) {
printk("there is already a secondary security module registered.\n");
return -EINVAL;
}
secondary_ops = ops;
printk("registering secondary module %s.\n",name);
return 0;
}
int t_unregister_security (const char *name, struct security_operations *ops)
{
if (ops != secondary_ops) {
printk("someone tried to unregister a security module that is not registered.\n");
return -EINVAL;
}
secondary_ops = original_ops;
return 0;
}
static struct security_operations lsrc_security_ops = {
.task_setuid = rootplug_task_setuid,
.register_security = t_register_security,
.unregister_security = t_unregister_security,
};
static int __init rootplug_init (void)
{
if(register_security (&lsrc_security_ops))
{
printk("1\n");
if(mod_reg_security(MY_NAME, &lsrc_security_ops))
{
printk("test\n");
return -EINVAL;
}
secondary = 1;
printk("LSM Loaded No Problem!!\n");
return 0;
}
}
static void __exit rootplug_exit (void)
{
if(secondary)
{
if(mod_unreg_security(MY_NAME, &lsrc_security_ops))
{
printk("what the!\n");
}
}
if(unregister_security(&lsrc_security_ops))
{
printk("!!!\n");
}
}
module_init (rootplug_init);
module_exit (rootplug_exit);
MODULE_LICENSE("GPL");
일단 소스는 위와 같고요..인터넷에서 짜맞춰서 컴파일까진 되게 해봤습니다만.
insmod 로 하니
[root@security gg]# insmod gg.ko
insmod: error inserting 'gg.ko': -1 Invalid parameters
[root@security gg]#
라는 에러메시지가 나옵니다. /var/log/messages 를 보니
Apr 2 16:15:46 security kernel: 1
Apr 2 16:15:46 security kernel: test
[root@security gg]#
라는 메시지가 있구요..음음..몇일 삽질 해보다가 도저히 모르겠어서 질문 올립니다..
혹시 SElinux 가 on 되어 있어야 하는건가요?
고수님들의 답변 기다리겠습니다~
댓글 달기