Hello Jeff Mahoney wrote: > 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@xxxxxxxx> > > -- > > fs/reiserfs/bitmap.c | 21 ++++++++++++++------- > 1 file changed, 14 insertions(+), 7 deletions(-) > > --- a/fs/reiserfs/bitmap.c 2007-05-30 15:43:39.000000000 -0400 > +++ b/fs/reiserfs/bitmap.c 2007-05-30 17:55:10.000000000 -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; > @@ -105,7 +104,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. */ > @@ -431,12 +429,21 @@ void reiserfs_free_block(struct reiserfs > int for_unformatted) > { > struct super_block *s = th->t_super; > + __u32 blocks = sb_block_count(REISERFS_SB(s)->s_rs); > > BUG_ON(!th->t_trans_id); > > RFALSE(!s, "vs-4061: trying to free block on nonexistent device"); s was dereferenced already to initialize blocks. It is too late to check whether it is NULL. > - RFALSE(is_reusable(s, block, 1) == 0, > - "vs-4071: can not free such block"); > + if (!is_reusable(s, block, 1)) > + return; > + > + if (block > blocks) { > + reiserfs_error(th->t_super, "bitmap-4072", there is s which can be used here. > + "Trying to free block outside file system " > + "boundaries (%lu > %lu)", > + block, blocks); > + return; > + } > /* mark it before we clear it, just in case */ > journal_mark_freed(th, s, block); > _reiserfs_free_block(th, inode, block, for_unformatted); > @@ -446,11 +453,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); > } > > - To unsubscribe from this list: send the line "unsubscribe reiserfs-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html