Jan Kara
2009-Aug-03 16:24 UTC
[Ocfs2-devel] [PATCH] ocfs2: Handle quota file corruption more gracefully
ocfs2_read_virt_blocks() does BUG when we try to read a block from a file beyond its end. Since this can happen due to filesystem corruption, it is not really an appropriate answer. Make ocfs2_read_quota_block() check the condition and handle it by calling ocfs2_error() and returning EIO. Reported-by: Tristan Ye <tristan.ye at oracle.com> Signed-off-by: Jan Kara <jack at suse.cz> --- Joel, could you please merge this fix? Thanks. fs/ocfs2/quota_global.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/fs/ocfs2/quota_global.c b/fs/ocfs2/quota_global.c index d604a6a..8988d8b 100644 --- a/fs/ocfs2/quota_global.c +++ b/fs/ocfs2/quota_global.c @@ -23,6 +23,7 @@ #include "sysfile.h" #include "dlmglue.h" #include "uptodate.h" +#include "super.h" #include "quota.h" static struct workqueue_struct *ocfs2_quota_wq = NULL; @@ -114,6 +115,14 @@ int ocfs2_read_quota_block(struct inode *inode, u64 v_block, int rc = 0; struct buffer_head *tmp = *bh; + if (i_size_read(inode) >> inode->i_sb->s_blocksize_bits <= v_block) { + ocfs2_error(inode->i_sb, + "Quota file %lu is probably corrupted! Requested " + "to read block %Lu but file has size only %Lu\n", + inode->i_ino, (unsigned long long)v_block, + (unsigned long long)i_size_read(inode)); + return -EIO; + } rc = ocfs2_read_virt_blocks(inode, v_block, 1, &tmp, 0, ocfs2_validate_quota_block); if (rc) -- 1.6.0.2
Joel Becker
2009-Aug-17 19:54 UTC
[Ocfs2-devel] [PATCH] ocfs2: Handle quota file corruption more gracefully
On Mon, Aug 03, 2009 at 06:24:21PM +0200, Jan Kara wrote:> ocfs2_read_virt_blocks() does BUG when we try to read a block from a file > beyond its end. Since this can happen due to filesystem corruption, it > is not really an appropriate answer. Make ocfs2_read_quota_block() check > the condition and handle it by calling ocfs2_error() and returning EIO. > > Reported-by: Tristan Ye <tristan.ye at oracle.com> > Signed-off-by: Jan Kara <jack at suse.cz> > --- > Joel, could you please merge this fix? Thanks.This is now in the fixes branch of ocfs2.git. That <= check is a little confusing, because it relies on quota files always being whole blocks. Joel -- "We'd better get back, `cause it'll be dark soon, and they mostly come at night. Mostly." Joel Becker Principal Software Developer Oracle E-mail: joel.becker at oracle.com Phone: (650) 506-8127
Seemingly Similar Threads
- [git patches] Ocfs2 patches for merge window, batch 2/3
- [PATCH 59/62] fs/ocfs2/quota_global.c: Remove unnecessary semicolons
- [PATCH] ocfs2/quota: Release lock for error in ocfs2_quota_write.
- [PATCH] ocfs2: Implement quota syncing thread
- [PATCH 1/1] OCFS2: use i_size_read() instead of direct accessing inode->i_size