From: Jan Kara <jack@suse.cz>
To: linux-ext4@vger.kernel.org
Cc: tytso@mit.edu
Subject: ext2fs_block_iterate() on fast symlink
Date: Wed, 20 Jun 2007 14:56:53 +0200 [thread overview]
Message-ID: <20070620125653.GG27218@duck.suse.cz> (raw)
[-- Attachment #1: Type: text/plain, Size: 514 bytes --]
Hello,
when ext2fs_block_iterate() is called on a fast symlink (and I assume
device inodes would be no different), then random things happen - the
problem is ext2fs_block_iterate() just blindly takes portions of the inode
and treats them as block numbers. Now I agree that garbage went in (it
makes no sence to call this function on such inode) so garbage results but
maybe it would be nicer to handle it more gracefully. Attached patch should
do it.
Honza
--
Jan Kara <jack@suse.cz>
SuSE CR Labs
[-- Attachment #2: e2fsprogs-block_iterate_fix.diff --]
[-- Type: text/x-patch, Size: 878 bytes --]
--- a/lib/ext2fs/inode.c 2007-06-20 13:55:52.000000000 +0200
+++ b/lib/ext2fs/inode.c 2007-06-20 14:11:15.000000000 +0200
@@ -771,6 +771,10 @@ errcode_t ext2fs_get_blocks(ext2_filsys
retval = ext2fs_read_inode(fs, ino, &inode);
if (retval)
return retval;
+ if (LINUX_S_ISCHR(inode.i_mode) || LINUX_S_ISBLK(inode.i_mode) ||
+ (LINUX_S_ISLNK(inode.i_mode) &&
+ ext2fs_inode_data_blocks(fs, &inode) == 0))
+ return EXT2_ET_INVAL_INODE_TYPE;
for (i=0; i < EXT2_N_BLOCKS; i++)
blocks[i] = inode.i_block[i];
return 0;
--- a/lib/ext2fs/ext2_err.et.in 2007-06-20 14:09:18.000000000 +0200
+++ b/lib/ext2fs/ext2_err.et.in 2007-06-20 14:11:25.000000000 +0200
@@ -296,5 +296,8 @@ ec EXT2_ET_RESIZE_INODE_CORRUPT,
ec EXT2_ET_SET_BMAP_NO_IND,
"Missing indirect block not present"
+ec EXT2_ET_INVAL_INODE_TYPE,
+ "Invalid inode type for the operation."
+
end
next reply other threads:[~2007-06-20 12:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-20 12:56 Jan Kara [this message]
2007-06-21 9:33 ` ext2fs_block_iterate() on fast symlink Andreas Dilger
2007-06-21 9:54 ` Jan Kara
2007-06-21 11:10 ` 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=20070620125653.GG27218@duck.suse.cz \
--to=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.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