From: Jeff Mahoney <jeffm@suse.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Linux Torvalds <torvalds@linux-foundation.org>
Cc: ReiserFS Development Mailing List <reiserfs-devel@vger.kernel.org>
Subject: [patch 3/7] reiserfs: use is_reusable to catch corruption
Date: Tue, 16 Oct 2007 19:02:13 -0400 [thread overview]
Message-ID: <20071016230258.686563000@suse.com> (raw)
In-Reply-To: 20071016230210.779927000@suse.com
[-- Attachment #1: patches.suse/reiserfs-use-is_reusable.diff --]
[-- Type: text/plain, Size: 2252 bytes --]
This patch builds in is_reusable() unconditionally and uses it to catch
corruption before it reaches the block freeing paths.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
--
fs/reiserfs/bitmap.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
--- a/fs/reiserfs/bitmap.c 2007-10-16 18:52:28.521843537 -0400
+++ b/fs/reiserfs/bitmap.c 2007-10-16 18:55:57.118721353 -0400
@@ -56,7 +56,6 @@ static inline void get_bit_address(struc
*offset = block & ((s->s_blocksize << 3) - 1);
}
-#ifdef CONFIG_REISERFS_CHECK
int is_reusable(struct super_block *s, b_blocknr_t block, int bit_value)
{
int bmap, offset;
@@ -106,7 +105,6 @@ int is_reusable(struct super_block *s, b
return 1;
}
-#endif /* CONFIG_REISERFS_CHECK */
/* searches in journal structures for a given block number (bmap, off). If block
is found in reiserfs journal it suggests next free block candidate to test. */
@@ -434,12 +432,19 @@ void reiserfs_free_block(struct reiserfs
int for_unformatted)
{
struct super_block *s = th->t_super;
-
BUG_ON(!th->t_trans_id);
RFALSE(!s, "vs-4061: trying to free block on nonexistent device");
- RFALSE(is_reusable(s, block, 1) == 0,
- "vs-4071: can not free such block");
+ if (!is_reusable(s, block, 1))
+ return;
+
+ if (block > sb_block_count(REISERFS_SB(s)->s_rs)) {
+ reiserfs_panic(th->t_super, "bitmap-4072",
+ "Trying to free block outside file system "
+ "boundaries (%lu > %lu)",
+ block, sb_block_count(REISERFS_SB(s)->s_rs));
+ return;
+ }
/* mark it before we clear it, just in case */
journal_mark_freed(th, s, block);
_reiserfs_free_block(th, inode, block, for_unformatted);
@@ -449,11 +454,11 @@ void reiserfs_free_block(struct reiserfs
static void reiserfs_free_prealloc_block(struct reiserfs_transaction_handle *th,
struct inode *inode, b_blocknr_t block)
{
+ BUG_ON(!th->t_trans_id);
RFALSE(!th->t_super,
"vs-4060: trying to free block on nonexistent device");
- RFALSE(is_reusable(th->t_super, block, 1) == 0,
- "vs-4070: can not free such block");
- BUG_ON(!th->t_trans_id);
+ if (!is_reusable(th->t_super, block, 1))
+ return;
_reiserfs_free_block(th, inode, block, 1);
}
--
next prev parent reply other threads:[~2007-10-16 23:02 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-16 23:02 [patch 0/7] reiserfs fixes patch set Jeff Mahoney
2007-10-16 23:02 ` [patch 1/7] reiserfs: fix up lockdep warnings Jeff Mahoney
2007-10-16 23:02 ` [patch 2/7] reiserfs: dont use BUG when panicking Jeff Mahoney
2007-10-16 23:02 ` Jeff Mahoney [this message]
2007-10-16 23:02 ` [patch 4/7] reiserfs: fix usage of signed ints for block numbers Jeff Mahoney
2007-10-16 23:02 ` [patch 5/7] reiserfs: fix memset byte count during resize Jeff Mahoney
2007-10-16 23:02 ` [patch 6/7] reiserfs: remove first_zero_hint Jeff Mahoney
2007-10-18 18:02 ` Jeff Mahoney
2007-10-16 23:02 ` [patch 7/7] reiserfs: ignore on disk s_bmap_nr value Jeff Mahoney
2007-10-17 22:19 ` Andrew Morton
2007-10-17 22:11 ` [patch 0/7] reiserfs fixes patch set Andrew Morton
2007-10-17 22:19 ` Linus Torvalds
2007-10-17 23:23 ` Jeff Mahoney
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=20071016230258.686563000@suse.com \
--to=jeffm@suse.com \
--cc=akpm@linux-foundation.org \
--cc=reiserfs-devel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.