From: Blaisorblade <blaisorblade@yahoo.it>
To: user-mode-linux-devel@lists.sourceforge.net
Cc: Jeff Dike <jdike@addtoit.com>, William Stearns <wstearns@pobox.com>
Subject: Re: [uml-devel] Possible hostfs uml kernel data corruption with missing host directory (fc6, 2.6.20-rc5-git3 on opteron)
Date: Thu, 15 Feb 2007 04:36:54 +0100 [thread overview]
Message-ID: <200702150436.54553.blaisorblade@yahoo.it> (raw)
In-Reply-To: <20070126151328.GA4436@ccure.user-mode-linux.org>
[-- Attachment #1: Type: text/plain, Size: 1359 bytes --]
On Friday 26 January 2007 16:13, Jeff Dike wrote:
> On Fri, Jan 26, 2007 at 04:07:05AM -0500, William Stearns wrote:
> > After bisecting the difference between the two root filesystems,
> > the critical change was a line in /etc/fstab:
> >
> > none /mirrors hostfs defaults,/home/mirrors 0 0
> >
> > Woah.
Ok, I think I have found it from code analisys (no testing done). Please test
the attached patch, since the bug is repeatable for you.
Ok, we have a double kfree inside hostfs_fill_sb_common; since name is
assigned to host_filename, it is owned by the inode, and freed both by dput
and by kfree(name).
The path from dput to the first free is:
dput->iput->hostfs_destroy_inode->kfree(... ->host_filename)
The simplest fix is to clear 'name' after assigning it to ->host_filename.
Patch attached - the second hunk is totally optional, it avoids a
kfree(NULL);. The goal was maximum simplicity here.
Also, I discovered that in read_inode, failure from file_type (which calls
lstat64) is ignored. read_name is subsequently called, it calls lstat again,
so this should not be a problem; however, the other call to file_type (in
init_inode) is also unchecked, and that is less robust.
--
Inform me of my mistakes, so I can add them to my list!
Paolo Giarrusso, aka Blaisorblade
http://www.user-mode-linux.org/~blaisorblade
[-- Attachment #2: hostfs-fix-double-free.diff --]
[-- Type: text/x-diff, Size: 1194 bytes --]
Subject: uml - hostfs: fix double free
From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Fix double free in the error path - when name is assigned into root_inode we do
not own it any more and we must not kfree() it - see patch for details.
Thanks to William Stearns for the initial report.
CC: William Stearns <wstearns@pobox.com>
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
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
@@ -966,6 +966,9 @@ static int hostfs_fill_sb_common(struct
goto out_put;
HOSTFS_I(root_inode)->host_filename = name;
+ /* Avoid that in the error path, iput(root_inode) frees again name through
+ * hostfs_destroy_inode! */
+ name = NULL;
err = -ENOMEM;
sb->s_root = d_alloc_root(root_inode);
@@ -977,7 +980,7 @@ static int hostfs_fill_sb_common(struct
/* No iput in this case because the dput does that for us */
dput(sb->s_root);
sb->s_root = NULL;
- goto out_free;
+ goto out;
}
return(0);
[-- Attachment #3: Type: text/plain, Size: 345 bytes --]
-------------------------------------------------------------------------
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
[-- Attachment #4: Type: text/plain, Size: 194 bytes --]
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
next prev parent reply other threads:[~2007-02-15 3:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-26 9:07 [uml-devel] Possible hostfs uml kernel data corruption with missing host directory (fc6, 2.6.20-rc5-git3 on opteron) William Stearns
2007-01-26 15:13 ` Jeff Dike
2007-01-26 20:16 ` William Stearns
2007-02-15 3:36 ` Blaisorblade [this message]
2007-02-15 4:42 ` Blaisorblade
2007-02-19 21:33 ` Blaisorblade
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=200702150436.54553.blaisorblade@yahoo.it \
--to=blaisorblade@yahoo.it \
--cc=jdike@addtoit.com \
--cc=user-mode-linux-devel@lists.sourceforge.net \
--cc=wstearns@pobox.com \
/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