mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Petr Vandrovec <vandrove@vc.cvut.cz>
To: Roman Zippel <zippel@linux-m68k.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [RFC] module fs or how to not break everything at once
Date: Wed, 20 Nov 2002 23:03:38 +0100	[thread overview]
Message-ID: <20021120220338.GA6079@vana> (raw)
In-Reply-To: <Pine.LNX.4.44.0211202013000.2113-100000@serv>

On Wed, Nov 20, 2002 at 10:06:01PM +0100, Roman Zippel wrote:
> 
> what a fool I am. ;-). ) OTOH it's pretty interesting to see that nobody 
> seems to care, as the kernel loader is now in everybody's kernel and if 
> everyone were happy, someone should be able tell me, why it should be kept 
> in the kernel.

Nobody is answering for almost hour, so I'll do...

It was surprise to me that after patching about 100 lines in my
kernel I can live without modules ;-) I cannot redistribute it because
of vmmon/vmnet are linked directly to kernel, but it works. Maybe
I should be constructive, and update module-init-tools to fit my
needs (-p, -s; error messages from insmod going to screen and
not to the dmesg by default..., post-install/pre-install/post-remove/pre-remove
support in modprobe), but after comparing size of modutils and
module-init-tools I'll just leave this job to others: it looks like 
fulltime job for couple of months.

> Below is a basic module fs implementation, which demonstrates an 
> alternative way of managing modules. It's reduced to the most basic 
> functionality needed to get modules working: map an object into kernel 
> space and start/stop a module. Everything else can and should be done in 
> user space. On top of this functionality it's easy to emulate the old 
> system calls, so old insmod/rmmod work just fine. This allows now to write 
> new module tools and when they are ready (this means we're also happy with 
> the new module interface), we can drop all the old syscalls. The new 

Nice, but...

> static ssize_t modfs_control_file_write(struct file *file, const char *buffer,
> 					size_t count, loff_t *ppos)
> {
> 	struct dentry *dentry;
> 	char *data;
> 
> 	data = __getname();
> 	if (!data)
> 		return -ENOMEM;
> 	count = min(count, (size_t)PATH_MAX - 1);
> 	if (!copy_from_user(data, buffer, count)) {
> 		data[count] = 0;
> 		if (!strncmp(data, "map ", 4)) {

... now when we have setxattr() in kernel, what about using
setxattr() on module directory instead of separate control file? 
I know, you cannot manage it with "echo" then, but it looks
strange that mkdir automatically creates control file while
rmdir does not remove it automatically... and without control
file, sys_delete_module() could then use simple setxattr/vfs_unlink/vfs_rmdir
instead of doing vfs's job by hand.

> 	down(&modfs_mount->mnt_sb->s_root->d_inode->i_sem);
> 	dentry = lookup_one_len(name, modfs_mount->mnt_sb->s_root, strlen(name));
> 	if (!IS_ERR(dentry)) {
> 		if (!dentry->d_inode)
> 			res = modfs_mkdir(modfs_mount->mnt_sb->s_root->d_inode, dentry, 0755);
> 		else
> 			res = -EEXIST;
> 	} else
> 		res = PTR_ERR(dentry);
> 	up(&modfs_mount->mnt_sb->s_root->d_inode->i_sem);

You are skipping security_ops hooks. Can you use vfs_mkdir() instead
of modfs_mkdir(), just to make sure that if someone adds some new
features into vfs_mkdir(), you'll not miss them ?

> asmlinkage long
> sys_delete_module(const char *name_user)
> {
> 	struct dentry *dentry;
> 	struct module_dir *moddir;
> 	char *name;
> 	long res = 0;
> 
> 	if (!capable(CAP_SYS_MODULE))
> 		return -EPERM;
> 
> 	if (!capable(CAP_SYS_MODULE))
> 		return -EPERM;

One pair of these lines is redundant...

And one minor comment: do you really need both module_dir->module
and module_data->module? Do you use it only to make sure that
sys_delete_module will not operate on modules not created by
sys_init_module? 

It has unfortunate feature that sys_create_module(); 
sys_delete_module() (without suceeding sys_init_module between
them) will return -ENOENT, and you'll have to use rm/rmdir to get 
rid of module :-(
					Thanks,
						Petr Vandrovec
						vandrove@vc.cvut.cz



  reply	other threads:[~2002-11-20 21:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-20 21:06 Roman Zippel
2002-11-20 22:03 ` Petr Vandrovec [this message]
2002-11-20 23:32   ` Roman Zippel
2002-11-21  1:59     ` Petr Vandrovec
2002-11-21 19:46       ` Roman Zippel
2002-11-21 23:21 Adam J. Richter
2002-11-22 10:50 ` Roman Zippel
2002-11-21 23:59 Adam J. Richter
2002-11-22 18:10 Adam J. Richter
2002-11-22 20:28 ` Roman Zippel
2002-11-22 22:11 Adam J. Richter
2002-11-22 23:24 ` Roman Zippel
2002-11-23  4:58 Adam J. Richter
2002-11-23 12:34 ` Roman Zippel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20021120220338.GA6079@vana \
    --to=vandrove@vc.cvut.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zippel@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®