This is a note to let you know that I've just added the patch titled
md: protect against NULL reference when waiting to start a raid10.
to the 2.6.36-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
md-protect-against-null-reference-when-waiting-to-start-a-raid10.patch
and it can be found in the queue-2.6.36 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree,
please let <[email protected]> know about it.
>From 589a594be1fb8815b3f18e517be696c48664f728 Mon Sep 17 00:00:00 2001
From: NeilBrown <[email protected]>
Date: Thu, 9 Dec 2010 17:02:14 +1100
Subject: md: protect against NULL reference when waiting to start a raid10.
From: NeilBrown <[email protected]>
commit 589a594be1fb8815b3f18e517be696c48664f728 upstream.
When we fail to start a raid10 for some reason, we call
md_unregister_thread to kill the thread that was created.
Unfortunately md_thread() will then make one call into the handler
(raid10d) even though md_wakeup_thread has not been called. This is
not safe and as md_unregister_thread is called after mddev->private
has been set to NULL, it will definitely cause a NULL dereference.
So fix this at both ends:
- md_thread should only call the handler if THREAD_WAKEUP has been
set.
- raid10 should call md_unregister_thread before setting things
to NULL just like all the other raid modules do.
This is applicable to 2.6.35 and later.
Reported-by: "Citizen" <[email protected]>
Signed-off-by: NeilBrown <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
drivers/md/md.c | 5 ++---
drivers/md/raid10.c | 2 +-
2 files changed, 3 insertions(+), 4 deletions(-)
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -6040,9 +6040,8 @@ static int md_thread(void * arg)
|| kthread_should_stop(),
thread->timeout);
- clear_bit(THREAD_WAKEUP, &thread->flags);
-
- thread->run(thread->mddev);
+ if (test_and_clear_bit(THREAD_WAKEUP, &thread->flags))
+ thread->run(thread->mddev);
}
return 0;
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -2396,13 +2396,13 @@ static int run(mddev_t *mddev)
return 0;
out_free_conf:
+ md_unregister_thread(mddev->thread);
if (conf->r10bio_pool)
mempool_destroy(conf->r10bio_pool);
safe_put_page(conf->tmppage);
kfree(conf->mirrors);
kfree(conf);
mddev->private = NULL;
- md_unregister_thread(mddev->thread);
out:
return -EIO;
}
Patches currently in stable-queue which might be from [email protected] are
queue-2.6.36/md-protect-against-null-reference-when-waiting-to-start-a-raid10.patch
queue-2.6.36/md-fix-bug-with-re-adding-of-partially-recovered-device.patch
queue-2.6.36/nfsd-fix-possible-bug_on-firing-in-set_change_info.patch
queue-2.6.36/sunrpc-prevent-use-after-free-on-clearing-xpt_busy.patch
_______________________________________________
stable mailing list
[email protected]
http://linux.kernel.org/mailman/listinfo/stable