From: Thiemo Nagel <thiemo.nagel@ph.tum.de>
To: Ext4 Developers List <linux-ext4@vger.kernel.org>,
Theodore Tso <tytso@mit.edu>
Subject: [RFC] ext4_bmap() may return blocks outside filesystem
Date: Thu, 05 Feb 2009 13:03:23 +0100 [thread overview]
Message-ID: <498AD58B.5000805@ph.tum.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 771 bytes --]
Hello,
during testing of ext4 with intentionally corrupted filesystem images I
noticed that sometimes ext4_bmap() returns physical block numbers which
lie outside of the filesystem. In most cases, the error is caught by
the block layer (?) leading to error messages of the kind:
attempt to access beyond end of device
loop0: rw=0, want=xxx, limit=xxx
But there also are cases which are not handled gracefully by bmap() callers.
I've attached a conceptual patch against 2.6.29-rc2 which fixes one case
in which invalid block numbers are returned (there might be more) by
adding sanity checks to ext4_ext_find_extent(), but before I start
looking for further occurences, I'd like to ask whether you think my
approach is reasonable.
Kind regards,
Thiemo Nagel
[-- Attachment #2: concept.patch --]
[-- Type: text/x-patch, Size: 788 bytes --]
--- ../download/linux-2.6.29-rc2-vanilla/fs/ext4/extents.c 2009-02-05 12:31:19.000000000 +0100
+++ fs/ext4/extents.c 2009-02-05 12:42:49.000000000 +0100
@@ -595,8 +595,15 @@
/* find extent */
ext4_ext_binsearch(inode, path + ppos, block);
/* if not an empty leaf */
- if (path[ppos].p_ext)
+ if (path[ppos].p_ext) {
path[ppos].p_block = ext_pblock(path[ppos].p_ext);
+ if (path[ppos].p_block < EXT4_SB(inode->i_sb)->s_es->s_first_data_block
+ || path[ppos].p_block + path[ppos].p_ext->ee_len
+ >= ext4_blocks_count(EXT4_SB(inode->i_sb)->s_es)) {
+ printk("ext4_ext_find_extent: extent out of range\n");
+ goto err;
+ }
+ }
ext4_ext_show_path(inode, path);
next reply other threads:[~2009-02-05 12:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-05 12:03 Thiemo Nagel [this message]
2009-02-05 13:49 ` [RFC] ext4_bmap() may return blocks outside filesystem Theodore Tso
2009-02-05 15:22 ` Greg Freemyer
2009-02-05 15:39 ` Ric Wheeler
2009-02-05 16:48 ` Theodore Tso
2009-02-05 22:01 ` Greg Freemyer
2009-02-05 22:18 ` Theodore Tso
2009-02-07 13:27 ` Goswin von Brederlow
2009-02-07 15:51 ` Theodore Tso
2009-02-07 18:20 ` Ric Wheeler
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=498AD58B.5000805@ph.tum.de \
--to=thiemo.nagel@ph.tum.de \
--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;
as well as URLs for NNTP newsgroup(s).