All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin Schitter <ms@mur.at>
To: grub-devel@gnu.org
Subject: [PATCH] segfault in grub-probe when spare or faulty disks are found
Date: Mon, 27 Sep 2010 22:32:54 +0200	[thread overview]
Message-ID: <4CA0FF76.90207@mur.at> (raw)

[-- Attachment #1: Type: text/plain, Size: 355 bytes --]

the actual raid implementation doesn't handle spare or faulty drives in 
a linux software raid array in a sane way. grub-probe will reproducible 
crash in such a setup.

please include the attached trivial patch to fix this problem.

for more information see:

https://savannah.gnu.org/bugs/?31119
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=593652


[-- Attachment #2: grub2-raid-better.diff --]
[-- Type: text/x-patch, Size: 1094 bytes --]

=== modified file 'grub-core/disk/raid.c'
--- grub-core/disk/raid.c	2010-09-13 21:59:22 +0000
+++ grub-core/disk/raid.c	2010-09-25 22:20:29 +0000
@@ -501,7 +501,8 @@
           grub_dprintf ("raid", "array->nr_devs > array->total_devs (%d)?!?",
 			array->total_devs);
 
-        if (array->device[new_array->index] != NULL)
+        if ((new_array->index < GRUB_RAID_MAX_DEVICES) &&
+	    (array->device[new_array->index] != NULL))
           /* We found multiple devices with the same number. Again,
              this shouldn't happen.  */
           grub_dprintf ("raid", "Found two disks with the number %d?!?",
@@ -609,9 +610,14 @@
     }
 
   /* Add the device to the array. */
-  array->device[new_array->index] = disk;
-  array->start_sector[new_array->index] = start_sector;
-  array->nr_devs++;
+
+  /* ignore spare/faulty disks and more then GRUB_RAID_MAX_DEVICES */
+  if (new_array->index < GRUB_RAID_MAX_DEVICES)
+    {
+      array->device[new_array->index] = disk;
+      array->start_sector[new_array->index] = start_sector;
+      array->nr_devs++;
+    }
 
   return 0;
 }


             reply	other threads:[~2010-09-28  8:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-27 20:32 Martin Schitter [this message]
2010-09-28 20:24 ` [PATCH] segfault in grub-probe when spare or faulty disks are found Vladimir 'φ-coder/phcoder' Serbinenko
2010-09-29 12:16   ` Martin Schitter
2010-10-25 11:07   ` Martin Schitter
2010-10-25 11:11     ` Vladimir 'φ-coder/phcoder' Serbinenko
2010-10-26  8:58 ` Vladimir 'φ-coder/phcoder' Serbinenko
2010-10-26 15:29   ` Martin Schitter

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=4CA0FF76.90207@mur.at \
    --to=ms@mur.at \
    --cc=grub-devel@gnu.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 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.