From: Eric Sandeen <sandeen@redhat.com>
To: Lukas Czerner <lczerner@redhat.com>
Cc: linux-ext4@vger.kernel.org, tytso@mit.edu
Subject: Re: [PATCH 4/4] ext4: fix possible use-after-free ext4_remove_li_request()
Date: Thu, 19 May 2011 15:05:59 -0500 [thread overview]
Message-ID: <4DD57827.9060104@redhat.com> (raw)
In-Reply-To: <1304956630-20384-4-git-send-email-lczerner@redhat.com>
On 5/9/11 10:57 AM, Lukas Czerner wrote:
> We need to take reference to the s_li_request after we take a mutex,
> because it might be freed since then, hence result in accessing old
> already freed memory. Also we should protect the whole
> ext4_remove_li_request() because ext4_li_info might be in the process of
> being freed in ext4_lazyinit_thread().
It'd be really great to have some comments which explain just what
ext4_li_mtx protects, but I'm working on an add-comments patch for
the lazyinit stuff (I commented things a bit as I reviewed your
changes) so I'll send that along later.
in any case, the change looks ok, thanks.
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
> Signed-off-by: Lukas Czerner <lczerner@redhat.com>
> ---
> fs/ext4/super.c | 10 ++++++----
> 1 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index c379af6..6a8e48f 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -2721,14 +2721,16 @@ static void ext4_remove_li_request(struct ext4_li_request *elr)
>
> static void ext4_unregister_li_request(struct super_block *sb)
> {
> - struct ext4_li_request *elr = EXT4_SB(sb)->s_li_request;
> -
> - if (!ext4_li_info)
> + mutex_lock(&ext4_li_mtx);
> + if (!ext4_li_info) {
> + mutex_unlock(&ext4_li_mtx);
> return;
> + }
>
> mutex_lock(&ext4_li_info->li_list_mtx);
> - ext4_remove_li_request(elr);
> + ext4_remove_li_request(EXT4_SB(sb)->s_li_request);
> mutex_unlock(&ext4_li_info->li_list_mtx);
> + mutex_unlock(&ext4_li_mtx);
> }
>
> static struct task_struct *ext4_lazyinit_task;
next prev parent reply other threads:[~2011-05-19 20:06 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-09 15:57 [PATCH 1/4 v2] ext4: Use schedule_timeout_interruptible() for waiting in lazyinit thread Lukas Czerner
2011-05-09 15:57 ` [PATCH 2/4 v2] ext4: Remove unnecessary wait_event ext4_run_lazyinit_thread() Lukas Czerner
2011-05-19 19:37 ` Eric Sandeen
2011-05-20 9:09 ` Lukas Czerner
2011-05-09 15:57 ` [PATCH 3/4] ext4: fix init_itable=n to work as expected for n=0 Lukas Czerner
2011-05-19 19:59 ` Eric Sandeen
2011-05-20 9:21 ` Lukas Czerner
2011-05-09 15:57 ` [PATCH 4/4] ext4: fix possible use-after-free ext4_remove_li_request() Lukas Czerner
2011-05-19 20:05 ` Eric Sandeen [this message]
2011-05-20 9:27 ` Lukas Czerner
2011-05-20 16:03 ` Ted Ts'o
2011-05-20 16:12 ` Eric Sandeen
2011-05-20 17:47 ` Ted Ts'o
2011-05-20 17:49 ` Eric Sandeen
2011-05-20 16:16 ` Lukas Czerner
2011-05-20 17:39 ` Ted Ts'o
2011-05-20 17:42 ` Ted Ts'o
2011-05-19 19:30 ` [PATCH 1/4 v2] ext4: Use schedule_timeout_interruptible() for waiting in lazyinit thread Eric Sandeen
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=4DD57827.9060104@redhat.com \
--to=sandeen@redhat.com \
--cc=lczerner@redhat.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).