udf: Fix memory corruption when fs mounted with noadinicb option

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <git-commits-head@...>
Date: Thursday, May 8, 2008 - 5:59 pm

Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=9afadc...
Commit:     9afadc4b1fd25337003832c9a4668f9bd42cdda9
Parent:     221e583a735fc5d879d83c2a76b8ee5afcbdf146
Author:     Jan Kara <jack@ghost.suse.cz>
AuthorDate: Tue May 6 18:26:17 2008 +0200
Committer:  Jan Kara <jack@suse.cz>
CommitDate: Wed May 7 09:49:52 2008 +0200

    udf: Fix memory corruption when fs mounted with noadinicb option
    
    When UDF filesystem is mounted with noadinicb mount option, it
    happens that we extend an empty directory with a block. A code in
    udf_add_entry() didn't count with this possibility and used
    uninitialized data leading to memory and filesystem corruption.
    Add a check whether file already has some extents before operating
    on them.
    
    Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/udf/namei.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index 47a6589..3d94bc1 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -315,7 +315,7 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
 	uint16_t liu;
 	int block;
 	kernel_lb_addr eloc;
-	uint32_t elen;
+	uint32_t elen = 0;
 	sector_t offset;
 	struct extent_position epos = {};
 	struct udf_inode_info *dinfo;
@@ -406,7 +406,8 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
 	}
 
 add:
-	if (dinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) {
+	/* Is there any extent whose size we need to round up? */
+	if (dinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB && elen) {
 		elen = (elen + sb->s_blocksize - 1) & ~(sb->s_blocksize - 1);
 		if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
 			epos.offset -= sizeof(short_ad);
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
udf: Fix memory corruption when fs mounted with noadinicb op..., Linux Kernel Mailing List..., (Thu May 8, 5:59 pm)