public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <jens.axboe@oracle.com>
To: npiggin@suse.de
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [patch 3/5] fs: fix bdi writeback use after free 1
Date: Tue, 15 Sep 2009 21:32:04 +0200	[thread overview]
Message-ID: <20090915193204.GU23126@kernel.dk> (raw)
In-Reply-To: <20090915192242.897829798@suse.de>

On Wed, Sep 16 2009, npiggin@suse.de wrote:
> By the time bdi_work_on_stack gets evaluated again in bdi_work_free, it
> cna already have been deallocated and used for something else in the
> !on stack case, giving a false positive in this test and causing corruption.

You are right, that is also buggy... Applied.

> 
> Signed-off-by: Nick Piggin <npiggin@suse.de>
> ---
>  fs/fs-writeback.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> Index: linux-2.6/fs/fs-writeback.c
> ===================================================================
> --- linux-2.6.orig/fs/fs-writeback.c
> +++ linux-2.6/fs/fs-writeback.c
> @@ -114,6 +114,7 @@ static void bdi_work_free(struct rcu_hea
>  static void wb_work_complete(struct bdi_work *work)
>  {
>  	const enum writeback_sync_modes sync_mode = work->sync_mode;
> +	int onstack = bdi_work_on_stack(work);
>  
>  	/*
>  	 * For allocated work, we can clear the done/seen bit right here.
> @@ -121,9 +122,9 @@ static void wb_work_complete(struct bdi_
>  	 * to after the RCU grace period, since the stack could be invalidated
>  	 * as soon as bdi_work_clear() has done the wakeup.
>  	 */
> -	if (!bdi_work_on_stack(work))
> +	if (!onstack)
>  		bdi_work_clear(work);
> -	if (sync_mode == WB_SYNC_NONE || bdi_work_on_stack(work))
> +	if (sync_mode == WB_SYNC_NONE || onstack)
>  		call_rcu(&work->rcu_head, bdi_work_free);
>  }
>  
> 
> 

-- 
Jens Axboe


  reply	other threads:[~2009-09-15 19:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-15 19:19 [patch 0/5] bdi writeback fixes npiggin
2009-09-15 19:19 ` [patch 1/5] fs: make use of rcu helpers npiggin
2009-09-15 19:31   ` Jens Axboe
2009-09-15 19:19 ` [patch 2/5] fs: improve scalability of bdi writeback work queues npiggin
2009-09-15 19:31   ` Jens Axboe
2009-09-15 19:19 ` [patch 3/5] fs: fix bdi writeback use after free 1 npiggin
2009-09-15 19:32   ` Jens Axboe [this message]
2009-09-15 19:19 ` [patch 4/5] fs: fix possible bdi writeback refcounting problem npiggin
2009-09-15 19:30   ` Jens Axboe
2009-09-15 19:19 ` [patch 5/5] fs: fix bdi writeback use after free 2 npiggin
2009-09-15 19:29   ` Jens Axboe

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=20090915193204.GU23126@kernel.dk \
    --to=jens.axboe@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=npiggin@suse.de \
    --cc=torvalds@linux-foundation.org \
    /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