From: Andreas Dilger <adilger@turbolinux.com>
To: pavel@suse.cz (Pavel Machek)
Cc: mason@suse.com (Chris Mason),
viro@math.psu.edu, linux-kernel@vger.kernel.org (kernel list),
jack@atrey.karlin.mff.cuni.cz, torvalds@transmeta.com
Subject: Re: [patch] linux likes to kill bad inodes
Date: Fri, 27 Apr 2001 16:07:56 -0600 (MDT) [thread overview]
Message-ID: <200104272207.QAA06020@lynx.turbolabs.com> (raw)
In-Reply-To: <20010427002853.A11426@bug.ucw.cz> from "Pavel Machek" at Apr 27, 2001 12:28:54 AM
Pavel writes:
> [I'd really like to get patch it; killing user's data without good
> reason seems evil to me, and this did quite a lot of damage to my
> $HOME.]
>
> Pavel
> PS: Only filesystem at use at time of problem was ext2, and it was
> ext2 iinode that got killed.
However, since make_bad_inode() only changes the file methods and not
the superblock, any of the put_inode(), delete_inode(), or write_inode()
methods can still be called. While the write_inode() call is safe to
block in the VFS, I don't think it is safe to block *_put_inode() and
*_delete_inode() in the VFS because the filesystem may have allocated
memory or other things that need to be undone even for bad inodes.
The following patch fixes the VFS write_inode() (per Pavel's patch),
and ext2_put_inode(), bfs_delete_inode(), and udf_put_inode() to not
do anything with bad inodes. I have bailed (with a FIXME) on
hpfs_delete_inode() and smb_delete_inode(), because I don't know what
(if anything) needs to be done to correctly clean up a bad inode.
I will post a patch separately which handles a couple of cases where
*_delete_inode() does not call clear_inode() in all cases.
Cheers, Andreas
=======================================================================
diff -ru linux-2.4.4p1.orig/fs/inode.c linux/fs/inode.c
--- linux-2.4.4p1.orig/fs/inode.c Tue Apr 10 16:44:49 2001
+++ linux/fs/inode.c Fri Apr 27 13:05:04 2001
@@ -179,6 +181,12 @@
static inline void write_inode(struct inode *inode, int sync)
{
+ if (is_bad_inode(inode)) {
+ printk(KERN_CRIT "Cowardly refusing to write bad inode %s:%d\n",+ kdevname(inode->i_dev), inode->i_ino);
+ return;
+ }
+
if (inode->i_sb && inode->i_sb->s_op && inode->i_sb->s_op->write_inode)
inode->i_sb->s_op->write_inode(inode, sync);
}
diff -ru linux-2.4.4p1.orig/fs/ext2/inode.c linux/fs/ext2/inode.c
--- linux-2.4.4p1.orig/fs/ext2/inode.c Tue Apr 10 16:44:49 2001
+++ linux/fs/ext2/inode.c Fri Apr 27 13:51:15 2001
@@ -36,6 +36,9 @@
*/
void ext2_put_inode (struct inode * inode)
{
+ if (is_bad_inode(inode))
+ return;
+
ext2_discard_prealloc (inode);
}
diff -ru linux-2.4.4p1.orig/fs/bfs/inode.c linux/fs/bfs/inode.c
--- linux-2.4.4p1.orig/fs/bfs/inode.c Tue Apr 10 16:44:49 2001
+++ linux/fs/bfs/inode.c Fri Apr 27 15:45:31 2001
@@ -142,7 +142,8 @@
dprintf("ino=%08lx\n", inode->i_ino);
- if (inode->i_ino < BFS_ROOT_INO || inode->i_ino > inode->i_sb->su_lasti) {
+ if (is_bad_inode(inode) || inode->i_ino < BFS_ROOT_INO ||
+ inode->i_ino > inode->i_sb->su_lasti) {
printf("invalid ino=%08lx\n", inode->i_ino);
return;
}
diff -ru linux-2.4.4p1.orig/fs/udf/inode.c linux/fs/udf/inode.c
--- linux-2.4.4p1.orig/fs/udf/inode.c Tue Apr 10 16:41:51 2001
+++ linux/fs/udf/inode.c Fri Apr 27 14:03:49 2001
@@ -74,7 +74,7 @@
*/
void udf_put_inode(struct inode * inode)
{
- if (!(inode->i_sb->s_flags & MS_RDONLY))
+ if (!(inode->i_sb->s_flags & MS_RDONLY) && !is_bad_inode(inode))
{
lock_kernel();
udf_discard_prealloc(inode);
diff -ru linux-2.4.4p1.orig/fs/hpfs/inode.c linux/fs/hpfs/inode.c
--- linux-2.4.4p1.orig/fs/hpfs/inode.c Tue Apr 10 16:41:50 2001
+++ linux/fs/hpfs/inode.c Fri Apr 27 13:57:12 2001
@@ -316,6 +304,7 @@
void hpfs_delete_inode(struct inode *inode)
{
+ /* FIXME: handle is_bad_inode??? */
lock_kernel();
hpfs_remove_fnode(inode->i_sb, inode->i_ino);
unlock_kernel();
diff -ru linux-2.4.4p1.orig/fs/smbfs/inode.c linux/fs/smbfs/inode.c
--- linux-2.4.4p1.orig/fs/smbfs/inode.c Tue Apr 10 16:44:54 2001
+++ linux/fs/smbfs/inode.c Fri Apr 27 14:01:33 2001
@@ -254,6 +254,7 @@
smb_delete_inode(struct inode *ino)
{
DEBUG1("ino=%ld\n", ino->i_ino);
+ /* FIXME: handle is_bad_inode() case??? */
lock_kernel();
if (smb_close(ino))
PARANOIA("could not close inode %ld\n", ino->i_ino);
--
Andreas Dilger TurboLabs filesystem development
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/
next prev parent reply other threads:[~2001-04-27 22:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-04-22 12:10 Pavel Machek
2001-04-25 13:29 ` Chris Mason
2001-04-25 20:01 ` Pavel Machek
2001-04-25 20:28 ` Chris Mason
2001-04-26 9:28 ` Pavel Machek
2001-04-26 9:33 ` Jan Kara
2001-04-26 22:28 ` Pavel Machek
2001-04-27 14:36 ` Chris Mason
2001-04-27 22:07 ` Andreas Dilger [this message]
2001-04-27 22:14 ` Linus Torvalds
2001-04-30 22:28 ` Alan Cox
2001-04-30 23:22 ` Linus Torvalds
2001-04-30 22:33 ` David S. Miller
[not found] <no.id>
2001-04-27 23:30 ` Andreas Dilger
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=200104272207.QAA06020@lynx.turbolabs.com \
--to=adilger@turbolinux.com \
--cc=jack@atrey.karlin.mff.cuni.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=mason@suse.com \
--cc=pavel@suse.cz \
--cc=torvalds@transmeta.com \
--cc=viro@math.psu.edu \
/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®