From: Andrea Righi <righi.andrea@gmail.com>
To: Jes Sorensen <jes@trained-monkey.org>
Cc: Robert LeBlanc <robert@leblancnet.us>, NeilBrown <neilb@suse.com>,
linux-raid@vger.kernel.org
Subject: [PATCH resubmit] Assemble: prevent segfault with faulty "best" devices
Date: Mon, 8 Jan 2018 19:23:46 +0100 [thread overview]
Message-ID: <20180108182346.GA16046@Dell> (raw)
In-Reply-To: <87bmnpsh43.fsf@notabene.neil.brown.name>
In Assemble(), after context reload, best[i] can be -1 in some cases,
and before checking if this value is negative we use it to access
devices[j].i.disk.raid_disk, potentially causing a segfault.
Check if best[i] is negative before using it to prevent this potential
segfault.
Regression was causes by commit 69a481166be6 ("Assemble array with write
journal").
Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Andrea Righi <andrea@betterlinux.com>
Signed-off-by: Robert LeBlanc <robert@leblancnet.us>
---
Assemble.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Assemble.c b/Assemble.c
index 3da0903..fc681eb 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -1669,6 +1669,8 @@ try_again:
int j = best[i];
unsigned int desired_state;
+ if (j < 0)
+ continue;
if (devices[j].i.disk.raid_disk == MD_DISK_ROLE_JOURNAL)
desired_state = (1<<MD_DISK_JOURNAL);
else if (i >= content->array.raid_disks * 2)
@@ -1678,8 +1680,6 @@ try_again:
else
desired_state = (1<<MD_DISK_ACTIVE) | (1<<MD_DISK_SYNC);
- if (j<0)
- continue;
if (!devices[j].uptodate)
continue;
next prev parent reply other threads:[~2018-01-08 18:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-08 17:48 [PATCH] Assemble: prevent segfault with faulty "best" devices Andrea Righi
2017-08-09 0:46 ` NeilBrown
2018-01-08 18:23 ` Andrea Righi [this message]
2018-01-21 21:38 ` Jes Sorensen
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=20180108182346.GA16046@Dell \
--to=righi.andrea@gmail.com \
--cc=jes@trained-monkey.org \
--cc=linux-raid@vger.kernel.org \
--cc=neilb@suse.com \
--cc=robert@leblancnet.us \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.