linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Theodore Tso <tytso@mit.edu>
To: Eric Sandeen <sandeen@redhat.com>
Cc: ext4 development <linux-ext4@vger.kernel.org>
Subject: Re: [PATCH] libext2fs: write only core inode in update_path()
Date: Wed, 17 Jun 2009 11:35:37 -0400	[thread overview]
Message-ID: <20090617153537.GB25451@mit.edu> (raw)
In-Reply-To: <4A383F97.1080002@redhat.com>

On Tue, Jun 16, 2009 at 07:57:59PM -0500, Eric Sandeen wrote:
> libext2fs: write only core inode in update_path()
> 
> The ext2_extent_handle only has a struct ext2_inode allocated on
> it, and the same amount copied into it in that same function, 
> but in update_path() we're possibly writing out more than that - 
> for example 256 bytes, from that address.  This causes uninitialized 
> memory to get  written to disk, overwriting the parts of the 
> inode past the osd2 member (the end of the smaller structure).

Oh, I see.  The bug was introduced by commit 84b239ae 


    libext2fs: add ext2fs_extent_open2
    
    The patch below adds a function, ext2fs_extent_open2(), that behaves
    as ext2fs_extent_open(), but will use the user-supplied inode
    structure when opening an extent instead of reading the inode from
    disk.  It also changes several of the calls to extent_open() to use
    this enhancement.
    
    Signed-off-by: Nic Case <number9652@yahoo.com>
    Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>

Which replaced ext2fs_read_inode_full with ext2fs_read_inode(); which
is fine, extents.c doesn't need to use the full inode; but it didn't
change ext2fs_write_inode_full() with ext2fs_write_inode().

> diff --git a/lib/ext2fs/extent.c b/lib/ext2fs/extent.c
> index b7eb617..0dfee62 100644
> --- a/lib/ext2fs/extent.c
> +++ b/lib/ext2fs/extent.c
> @@ -547,7 +547,7 @@ static errcode_t update_path(ext2_extent_handle_t handle)
>  
>  	if (handle->level == 0) {
>  		retval = ext2fs_write_inode_full(handle->fs, handle->ino,
> -			   handle->inode, EXT2_INODE_SIZE(handle->fs->super));
> +			   handle->inode, sizeof(struct ext2_inode));

Probably it would be better/simpler to replace this with:

		retval = ext2fs_write_inode(handle->fs, handle->ino,
					    handle->inode);

							- Ted

  reply	other threads:[~2009-06-17 15:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-16 22:38 Something wrong with extent-based journal creation Eric Sandeen
2009-06-17  0:57 ` [PATCH] libext2fs: write only core inode in update_path() Eric Sandeen
2009-06-17 15:35   ` Theodore Tso [this message]
2009-06-17 15:50     ` Eric Sandeen
2009-06-17 22:50       ` Theodore Tso
2009-06-17 23:00         ` Eric Sandeen
2009-06-17  8:04 ` Something wrong with extent-based journal creation Andreas Dilger
2009-06-17 14:45   ` Eric Sandeen
2009-06-17 15:31   ` Theodore Tso
  -- strict thread matches above, loose matches on Subject: below --
2009-06-17 20:11 [PATCH] libext2fs: write only core inode in update_path() number9652
2009-06-17 20:43 ` Eric Sandeen
2009-06-17 21:32 number9652
2009-06-17 21:36 ` Eric Sandeen
2009-06-17 22:46 ` Theodore Tso

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=20090617153537.GB25451@mit.edu \
    --to=tytso@mit.edu \
    --cc=linux-ext4@vger.kernel.org \
    --cc=sandeen@redhat.com \
    /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).