From: Eryu Guan <guaneryu@gmail.com>
To: Theodore Ts'o <tytso@mit.edu>
Cc: linux-ext4@vger.kernel.org
Subject: Re: [PATCH] ext4: fix NULL pointer dereference in ext4_mark_inode_dirty()
Date: Sun, 13 Mar 2016 15:07:45 +0800 [thread overview]
Message-ID: <20160313070744.GH4672@eguan.usersys.redhat.com> (raw)
In-Reply-To: <20160313023922.GA29218@thunk.org>
On Sat, Mar 12, 2016 at 09:39:22PM -0500, Theodore Ts'o wrote:
> On Fri, Mar 11, 2016 at 11:38:53PM +0800, Eryu Guan wrote:
> > ext4_reserve_inode_write() in ext4_mark_inode_dirty() could fail on
> > error (e.g. EIO) and iloc.bh can be NULL in this case. But the error is
> > ignored in the following "if" condition and ext4_expand_extra_isize()
> > might be called with NULL iloc.bh set, which triggers NULL pointer
> > dereference.
>
> Nice catch! I'm going fix this slightly differently (although I'll
> keep your description). The patch is a wee bit bigger, but the end
> result is simpler to read.
Yes, it's more easier to read. Thanks!
Eryu
>
> Thanks,
>
> - Ted
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index ce2c4c6..b41432e 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -5312,6 +5312,8 @@ int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode)
> might_sleep();
> trace_ext4_mark_inode_dirty(inode, _RET_IP_);
> err = ext4_reserve_inode_write(handle, inode, &iloc);
> + if (err)
> + return err;
> if (ext4_handle_valid(handle) &&
> EXT4_I(inode)->i_extra_isize < sbi->s_want_extra_isize &&
> !ext4_test_inode_state(inode, EXT4_STATE_NO_EXPAND)) {
> @@ -5342,9 +5344,7 @@ int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode)
> }
> }
> }
> - if (!err)
> - err = ext4_mark_iloc_dirty(handle, inode, &iloc);
> - return err;
> + return ext4_mark_iloc_dirty(handle, inode, &iloc);
> }
>
> /*
prev parent reply other threads:[~2016-03-13 7:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-11 15:38 [PATCH] ext4: fix NULL pointer dereference in ext4_mark_inode_dirty() Eryu Guan
2016-03-13 2:39 ` Theodore Ts'o
2016-03-13 7:07 ` Eryu Guan [this message]
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=20160313070744.GH4672@eguan.usersys.redhat.com \
--to=guaneryu@gmail.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/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).