* Bug/misfeature of "securityfs"
@ 2008-05-26 10:36 Markku Savela
2008-05-27 0:20 ` James Morris
0 siblings, 1 reply; 6+ messages in thread
From: Markku Savela @ 2008-05-26 10:36 UTC (permalink / raw)
To: linux-kernel
I write a module which creates a securityfs on init
foobar = securityfs_create_dir("foobar", NULL)
and on exit it does
security_fs_remove(foobar);
When I do "insmod" and "rmmod", I see
/sys/kernel/security/foobar/
appear and go away.
Now, if have a shell and do "cd /sys/kernel/security/foobar", the
"rmmod" does not remove the directory. The directory disappears when I
exit the shell from it via "cd ..". This is fine, and as it should be,
but....
IF, while having the shell in the directory, I try to "insmod" again,
the insmod fails with "-1 File exists". Again, understandable, BUT
when after this I exit the shell from the directory, IT DOES NOT GO
AWAY. It's permanetly existing, and module install fails always with
"File Exists".
Is this a bug, or am doing something wrong?
The kernel is Ubuntu Hardy heron
2.6.24-16-generic #1 SMP Thu Apr 10 13:23:42 UTC 2008 i686
--
Markku Savela
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Bug/misfeature of "securityfs"
2008-05-26 10:36 Bug/misfeature of "securityfs" Markku Savela
@ 2008-05-27 0:20 ` James Morris
2008-05-27 3:52 ` Greg KH
0 siblings, 1 reply; 6+ messages in thread
From: James Morris @ 2008-05-27 0:20 UTC (permalink / raw)
To: Markku Savela; +Cc: linux-kernel, linux-security-module, Greg KH
On Mon, 26 May 2008, Markku Savela wrote:
>
> I write a module which creates a securityfs on init
>
> foobar = securityfs_create_dir("foobar", NULL)
> and on exit it does
> security_fs_remove(foobar);
>
> When I do "insmod" and "rmmod", I see
>
> /sys/kernel/security/foobar/
>
> appear and go away.
>
> Now, if have a shell and do "cd /sys/kernel/security/foobar", the
> "rmmod" does not remove the directory. The directory disappears when I
> exit the shell from it via "cd ..". This is fine, and as it should be,
> but....
>
> IF, while having the shell in the directory, I try to "insmod" again,
> the insmod fails with "-1 File exists". Again, understandable, BUT
> when after this I exit the shell from the directory, IT DOES NOT GO
> AWAY. It's permanetly existing, and module install fails always with
> "File Exists".
>
> Is this a bug, or am doing something wrong?
>
> The kernel is Ubuntu Hardy heron
> 2.6.24-16-generic #1 SMP Thu Apr 10 13:23:42 UTC 2008 i686
Sounds like a bug.
--
James Morris
<jmorris@namei.org>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Bug/misfeature of "securityfs"
2008-05-27 0:20 ` James Morris
@ 2008-05-27 3:52 ` Greg KH
2008-05-27 5:44 ` Markku Savela
2008-05-27 7:17 ` Markku Savela
0 siblings, 2 replies; 6+ messages in thread
From: Greg KH @ 2008-05-27 3:52 UTC (permalink / raw)
To: James Morris; +Cc: Markku Savela, linux-kernel, linux-security-module
On Tue, May 27, 2008 at 10:20:17AM +1000, James Morris wrote:
> On Mon, 26 May 2008, Markku Savela wrote:
>
> >
> > I write a module which creates a securityfs on init
> >
> > foobar = securityfs_create_dir("foobar", NULL)
> > and on exit it does
> > security_fs_remove(foobar);
> >
> > When I do "insmod" and "rmmod", I see
> >
> > /sys/kernel/security/foobar/
> >
> > appear and go away.
> >
> > Now, if have a shell and do "cd /sys/kernel/security/foobar", the
> > "rmmod" does not remove the directory. The directory disappears when I
> > exit the shell from it via "cd ..". This is fine, and as it should be,
> > but....
> >
> > IF, while having the shell in the directory, I try to "insmod" again,
> > the insmod fails with "-1 File exists". Again, understandable, BUT
> > when after this I exit the shell from the directory, IT DOES NOT GO
> > AWAY. It's permanetly existing, and module install fails always with
> > "File Exists".
> >
> > Is this a bug, or am doing something wrong?
Yeah, the whole sequence above is "wrong" :)
How is the file always sticking around? Can you still see it in other
shells? Is a process still located there somehow?
securityfs is just using libfs for all of this, there shouldn't be any
problem here, unless it is also present there.
Or maybe we aren't cleaning up properly on the "file exists" code path?
Care to look into that?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Bug/misfeature of "securityfs"
2008-05-27 3:52 ` Greg KH
@ 2008-05-27 5:44 ` Markku Savela
2008-05-27 7:17 ` Markku Savela
1 sibling, 0 replies; 6+ messages in thread
From: Markku Savela @ 2008-05-27 5:44 UTC (permalink / raw)
To: Greg KH; +Cc: jmorris, linux-kernel, linux-security-module
> From: Greg KH <greg@kroah.com>
> On Tue, May 27, 2008 at 10:20:17AM +1000, James Morris wrote:
> > On Mon, 26 May 2008, Markku Savela wrote:
> >
> > >
> > > I write a module which creates a securityfs on init
> > >
> > > foobar = securityfs_create_dir("foobar", NULL)
> > > and on exit it does
> > > security_fs_remove(foobar);
> > >
> > > When I do "insmod" and "rmmod", I see
> > >
> > > /sys/kernel/security/foobar/
> > >
> > > appear and go away.
> > >
> > > Now, if have a shell and do "cd /sys/kernel/security/foobar", the
> > > "rmmod" does not remove the directory. The directory disappears when I
> > > exit the shell from it via "cd ..". This is fine, and as it should be,
> > > but....
> > >
> > > IF, while having the shell in the directory, I try to "insmod" again,
> > > the insmod fails with "-1 File exists". Again, understandable, BUT
> > > when after this I exit the shell from the directory, IT DOES NOT GO
> > > AWAY. It's permanetly existing, and module install fails always with
> > > "File Exists".
> > >
> > > Is this a bug, or am doing something wrong?
>
> Yeah, the whole sequence above is "wrong" :)
>
> How is the file always sticking around? Can you still see it in other
> shells? Is a process still located there somehow?
>
> securityfs is just using libfs for all of this, there shouldn't be any
> problem here, unless it is also present there.
>
> Or maybe we aren't cleaning up properly on the "file exists" code path?
> Care to look into that?
>
> thanks,
>
> greg k-h
I think my original description is somewhat misleading: the file
exists seems to come from the "insmod" for the module, not for the
seurityfs directory, becuase it appears to think that the module is
still loaded (while lsmod does not show it).
The directory is visible from other shells.
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Bug/misfeature of "securityfs"
2008-05-27 3:52 ` Greg KH
2008-05-27 5:44 ` Markku Savela
@ 2008-05-27 7:17 ` Markku Savela
2008-06-06 2:16 ` Greg KH
1 sibling, 1 reply; 6+ messages in thread
From: Markku Savela @ 2008-05-27 7:17 UTC (permalink / raw)
To: Greg KH; +Cc: jmorris, linux-kernel, linux-security-module
I should not really reply from hip in the morning, ignore more
previous message. The "file exists" definitely comes from the module
init failing, because it finds the directory existing.
Here is some more detailed information and a test module
(unfortunately, just pasted in this message):
*shell1*
*shell2*
> cd /sys/kernel/security/
> ls
apparmor
> sudo insmod foobar.ko
> ls
apparmor foobar
> sudo rmmod foobar.ko
> ls
apparmor
// so far fine, directory comes and goes...
> sudo insmod foobar.ko
> ls
apparmor foobar
> cd foobar/
> sudo rmmod foobar.ko
> ls /sys/kernel/security/
apparmor foobar
> cd ..
> ls /sys/kernel/security/
apparmor
// so far fine, directory goes when
// other shell exits it.
> sudo insmod foobar.ko
> cd foobar/
> sudo rmmod foobar.ko
> ls /sys/kernel/security/
apparmor foobar
> sudo insmod foobar.ko
insmod: error inserting 'foobar.ko': -1 File exists
> cd ..
> ls
apparmor foobar
// 'foobar' still exists, while module unloaded
// and shell also is out.
> ls /sys/kernel/security/
apparmor foobar
> ls /sys/kernel/security/
apparmor foobar
> sudo insmod foobar.ko
insmod: error inserting 'foobar.ko': -1 File exists
// And, now only reboot seems to remove the directory"
-------------------------------------------------------------------
tail /var/log/syslog
May 27 09:49:13 maja kernel: [ 192.771424] foobar: Module 'foobar' loaded
May 27 09:49:28 maja kernel: [ 207.637838] foobar: Module 'foobar' unloaded
May 27 09:49:35 maja kernel: [ 214.890241] foobar: Module 'foobar' loaded
May 27 09:49:46 maja kernel: [ 225.719495] foobar: Module 'foobar' unloaded
May 27 09:50:19 maja kernel: [ 258.782263] foobar: Module 'foobar' loaded
May 27 09:50:27 maja kernel: [ 266.641655] foobar: Module 'foobar' unloaded
May 27 09:50:48 maja kernel: [ 288.383145] foobar: Foobar FS create failed
May 27 09:51:11 maja kernel: [ 311.323851] foobar: Foobar FS create failed
------------------------------------------------------------------
#include <linux/init.h>
#include <linux/module.h>
#include <linux/security.h>
#define FOOBAR_NAME "foobar"
#undef DBG
#undef DBGG
#undef INFO
#undef ERR
#ifdef FOOBAR_DEBUG
# define DBG(args...) printk(KERN_DEBUG FOOBAR_NAME ": " args)
#else
# define DBG(args...)
#endif
#define DBGG(args...)
#define INFO(args...) printk(KERN_INFO FOOBAR_NAME ": " args)
#define ERR(args...) printk(KERN_ERR FOOBAR_NAME ": " args)
static struct dentry* foobar_fs;
static void foobar_cleanup(void)
{
if (foobar_fs && !IS_ERR(foobar_fs))
{
securityfs_remove(foobar_fs);
};
}
static int __init foobar_init(void)
{
DBG("foobar_init\n");
if (foobar_fs)
{
ERR("Foobar FS already exists\n");
return -EEXIST;
}
foobar_fs = securityfs_create_dir(FOOBAR_NAME, NULL);
if (IS_ERR(foobar_fs))
{
ERR("Foobar FS create failed\n");
foobar_cleanup();
return PTR_ERR(foobar_fs);
}
INFO("Module 'foobar' loaded\n");
return 0;
}
static void __exit foobar_exit(void)
{
DBG("foobar_exit\n");
foobar_cleanup();
INFO("Module 'foobar' unloaded\n");
}
module_init(foobar_init);
module_exit(foobar_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Markku Savela");
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Bug/misfeature of "securityfs"
2008-05-27 7:17 ` Markku Savela
@ 2008-06-06 2:16 ` Greg KH
0 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2008-06-06 2:16 UTC (permalink / raw)
To: Markku Savela; +Cc: jmorris, linux-kernel, linux-security-module
On Tue, May 27, 2008 at 10:17:53AM +0300, Markku Savela wrote:
> I should not really reply from hip in the morning, ignore more
> previous message. The "file exists" definitely comes from the module
> init failing, because it finds the directory existing.
>
> Here is some more detailed information and a test module
> (unfortunately, just pasted in this message):
<snip>
Hm, yeah, that doesn't look good at all :(
Any thoughts as to if you would have time to look into fixing this?
This isn't anything a normal user would ever hit, so I have a lot higher
priority things to handle at the moment, and it will be a while before I
could get to this.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-06-06 6:09 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-26 10:36 Bug/misfeature of "securityfs" Markku Savela
2008-05-27 0:20 ` James Morris
2008-05-27 3:52 ` Greg KH
2008-05-27 5:44 ` Markku Savela
2008-05-27 7:17 ` Markku Savela
2008-06-06 2:16 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®