On Friday 02 March 2007 22:55, Sylvain Beucler wrote:
> Hi,
>
> On Fri, Mar 02, 2007 at 01:07:49AM +0100, Blaisorblade wrote:
> > On Friday 02 March 2007 00:04, Sylvain Beucler wrote:
> > > Hi,
> > >
> > > I'm using a 2.6.20-um host on a 2.6.20-skas3-v8.2 host.
> > >
> > > When specifying hostfs=/tmp on the kernel command line, then:
> > >
> > > - mount none -t hostfs mount-point/
> > > -> mounts the host's /tmp (good), but
> > >
> > > - mount none -t hostfs mount-point/ -o /
> > > -> mounts the hosts "/" (bad).
> > >
> > > I think it's a bug.
> >
> > Yes, it is.
> >
> > > This doesn't happen in Jeff's 2.6.19rc5 kernel.
> >
> > You mean a tree with patches from
> >
> > http://user-mode-linux.sourceforge.net/patches.html?
>
> I meant this one:
> http://user-mode-linux.sourceforge.net/new/linux-2.6.19-rc5.bz2
> linked from the new/ homepage.
Guess what I said is valid but I cannot be sure.
However, I just tested the attached fix - the bug was easy to find and fix.
Please test and report.
--
Inform me of my mistakes, so I can add them to my list!
Paolo Giarrusso, aka Blaisorblade
http://www.user-mode-linux.org/~blaisorblade
Index: linux-2.6.git/fs/hostfs/hostfs_kern.c
===================================================================
--- linux-2.6.git.orig/fs/hostfs/hostfs_kern.c
+++ linux-2.6.git/fs/hostfs/hostfs_kern.c
@@ -939,7 +939,7 @@ static const struct address_space_operat
static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent)
{
struct inode *root_inode;
- char *name, *data = d;
+ char *host_root_path, *data = d;
int err;
sb->s_blocksize = 1024;
@@ -947,15 +947,17 @@ static int hostfs_fill_sb_common(struct
sb->s_magic = HOSTFS_SUPER_MAGIC;
sb->s_op = &hostfs_sbops;
- if((data == NULL) || (*data == '\0'))
- data = root_ino;
+ /* NULL is printed as <NULL> by sprintf: avoid that. */
+ if (data == NULL)
+ data = "";
err = -ENOMEM;
- name = kmalloc(strlen(data) + 1, GFP_KERNEL);
- if(name == NULL)
+ host_root_path = kmalloc(strlen(root_ino) + 1
+ + strlen(data) + 1, GFP_KERNEL);
+ if(host_root_path == NULL)
goto out;
- strcpy(name, data);
+ sprintf(host_root_path, "%s/%s", root_ino, data);
root_inode = iget(sb, 0);
if(root_inode == NULL)
@@ -965,10 +967,10 @@ static int hostfs_fill_sb_common(struct
if(err)
goto out_put;
- HOSTFS_I(root_inode)->host_filename = name;
- /* Avoid that in the error path, iput(root_inode) frees again name through
+ HOSTFS_I(root_inode)->host_filename = host_root_path;
+ /* Avoid that in the error path, iput(root_inode) frees again host_root_path through
* hostfs_destroy_inode! */
- name = NULL;
+ host_root_path = NULL;
err = -ENOMEM;
sb->s_root = d_alloc_root(root_inode);
@@ -988,7 +990,7 @@ static int hostfs_fill_sb_common(struct
out_put:
iput(root_inode);
out_free:
- kfree(name);
+ kfree(host_root_path);
out:
return(err);
}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
User-mode-linux-user mailing list
User-mode-linux-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-user