From: Jonathan Brassow <jbrassow@f14.redhat.com>
To: linux-raid@vger.kernel.org
Subject: [PATCH 3 of 9] MD: allow analyze_sbs to fail
Date: Mon, 23 May 2011 22:06:20 -0500 [thread overview]
Message-ID: <201105240306.p4O36Kvt029366@f14.redhat.com> (raw)
Patch name: md-allow-analyze_sbs-to-fail.patch
Catch the case that md_run is called requiring non-existant super_types fns.
Other modules may call md_run (like device-mapper's, dm-raid.c), we mustn't
assume they will always set a valid MD major_version. This is especially true
in the case of device-mapper, which will use a new superblock type. If patches
don't land in the kernel in the proper order, access will be attempted beyond
the end of the super_types array.
Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
Index: linux-2.6/drivers/md/md.c
===================================================================
--- linux-2.6.orig/drivers/md/md.c
+++ linux-2.6/drivers/md/md.c
@@ -2864,12 +2864,15 @@ abort_free:
*/
-static void analyze_sbs(mddev_t * mddev)
+static int analyze_sbs(mddev_t *mddev)
{
int i;
mdk_rdev_t *rdev, *freshest, *tmp;
char b[BDEVNAME_SIZE];
+ if (mddev->major_version >= ARRAY_SIZE(super_types))
+ return -EINVAL;
+
freshest = NULL;
rdev_for_each(rdev, tmp, mddev)
switch (super_types[mddev->major_version].
@@ -2921,6 +2924,7 @@ static void analyze_sbs(mddev_t * mddev)
clear_bit(In_sync, &rdev->flags);
}
}
+ return 0;
}
/* Read a fixed-point number.
@@ -4459,7 +4463,8 @@ int md_run(mddev_t *mddev)
if (should_read_super(mddev)) {
if (!mddev->persistent)
return -EINVAL;
- analyze_sbs(mddev);
+ if (analyze_sbs(mddev))
+ return -EINVAL;
}
if (mddev->level != LEVEL_NONE)
reply other threads:[~2011-05-24 3:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=201105240306.p4O36Kvt029366@f14.redhat.com \
--to=jbrassow@f14.redhat.com \
--cc=linux-raid@vger.kernel.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