summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authoroster <oster@NetBSD.org>2011-07-29 19:55:50 +0000
committeroster <oster@NetBSD.org>2011-07-29 19:55:50 +0000
commitdf7043f83ce27dcbe57cd44199dcc2180d70ba7e (patch)
treef4e197150a9563e0eb608f5f176f14f2e0088bd3 /sys/dev
parent82a29cd91aecaa37b93975754423af997c3642fa (diff)
In rf_disks.c make sure ser_values and ser_count arrays are
initialized before use. Validate the component label before considering a component for use, and make sure we only consider components that are optimal. Fixes PR#44251. All atf RAIDframe tests now pass.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/raidframe/rf_disks.c26
-rw-r--r--sys/dev/raidframe/rf_kintf.h4
-rw-r--r--sys/dev/raidframe/rf_netbsdkintf.c11
3 files changed, 33 insertions, 8 deletions
diff --git a/sys/dev/raidframe/rf_disks.c b/sys/dev/raidframe/rf_disks.c
index e60e3da0902..8d3ed9b76cb 100644
--- a/sys/dev/raidframe/rf_disks.c
+++ b/sys/dev/raidframe/rf_disks.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_disks.c,v 1.79 2011/05/11 18:13:12 mrg Exp $ */
+/* $NetBSD: rf_disks.c,v 1.80 2011/07/29 19:55:50 oster Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -60,7 +60,7 @@
***************************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.79 2011/05/11 18:13:12 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.80 2011/07/29 19:55:50 oster Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -136,6 +136,11 @@ rf_ConfigureDisks(RF_ShutdownList_t **listp, RF_Raid_t *raidPtr,
ret = raidfetch_component_label(raidPtr, c);
if (ret)
goto fail;
+
+ /* mark it as failed if the label looks bogus... */
+ if (!rf_reasonable_label(&raidPtr->raid_cinfo[c].ci_label,0) && !force) {
+ disks[c].status = rf_ds_failed;
+ }
}
if (disks[c].status != rf_ds_optimal) {
@@ -749,7 +754,12 @@ rf_CheckLabels(RF_Raid_t *raidPtr, RF_Config_t *cfgPtr)
num_ser = 0;
num_mod = 0;
+ ser_values[0] = ser_values[1] = ser_values[2] = ser_values[3] = 0;
+ ser_count[0] = ser_count[1] = ser_count[2] = ser_count[3] = 0;
+
for (c = 0; c < raidPtr->numCol; c++) {
+ if (raidPtr->Disks[c].status != rf_ds_optimal)
+ continue;
ci_label = raidget_component_label(raidPtr, c);
found=0;
for(i=0;i<num_ser;i++) {
@@ -805,6 +815,8 @@ rf_CheckLabels(RF_Raid_t *raidPtr, RF_Config_t *cfgPtr)
}
for (c = 0; c < raidPtr->numCol; c++) {
+ if (raidPtr->Disks[c].status != rf_ds_optimal)
+ continue;
ci_label = raidget_component_label(raidPtr, c);
if (serial_number != ci_label->serial_number) {
hosed_column = c;
@@ -860,6 +872,9 @@ rf_CheckLabels(RF_Raid_t *raidPtr, RF_Config_t *cfgPtr)
}
for (c = 0; c < raidPtr->numCol; c++) {
+ if (raidPtr->Disks[c].status != rf_ds_optimal)
+ continue;
+
ci_label = raidget_component_label(raidPtr, c);
if (mod_number != ci_label->mod_counter) {
if (hosed_column == c) {
@@ -920,6 +935,13 @@ rf_CheckLabels(RF_Raid_t *raidPtr, RF_Config_t *cfgPtr)
fatal_error = 1;
}
+ for (c = 0; c < raidPtr->numCol; c++) {
+ if (raidPtr->Disks[c].status != rf_ds_optimal) {
+ hosed_column = c;
+ break;
+ }
+ }
+
/* we start by assuming the parity will be good, and flee from
that notion at the slightest sign of trouble */
diff --git a/sys/dev/raidframe/rf_kintf.h b/sys/dev/raidframe/rf_kintf.h
index 1f80c14ab61..7939cf0a8f1 100644
--- a/sys/dev/raidframe/rf_kintf.h
+++ b/sys/dev/raidframe/rf_kintf.h
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_kintf.h,v 1.21 2009/11/17 18:54:26 jld Exp $ */
+/* $NetBSD: rf_kintf.h,v 1.22 2011/07/29 19:55:50 oster Exp $ */
/*
* rf_kintf.h
*
@@ -37,6 +37,8 @@
#include <dev/raidframe/raidframevar.h>
int rf_GetSpareTableFromDaemon(RF_SparetWait_t * req);
+int rf_reasonable_label(RF_ComponentLabel_t *, uint64_t);
+
void raidstart(RF_Raid_t * raidPtr);
int rf_DispatchKernelIO(RF_DiskQueue_t * queue, RF_DiskQueueData_t * req);
diff --git a/sys/dev/raidframe/rf_netbsdkintf.c b/sys/dev/raidframe/rf_netbsdkintf.c
index 7cda280f9c8..6ea923de366 100644
--- a/sys/dev/raidframe/rf_netbsdkintf.c
+++ b/sys/dev/raidframe/rf_netbsdkintf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_netbsdkintf.c,v 1.291 2011/05/11 18:13:12 mrg Exp $ */
+/* $NetBSD: rf_netbsdkintf.c,v 1.292 2011/07/29 19:55:50 oster Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
***********************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.291 2011/05/11 18:13:12 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.292 2011/07/29 19:55:50 oster Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -297,7 +297,7 @@ void rf_buildroothack(RF_ConfigSet_t *);
RF_AutoConfig_t *rf_find_raid_components(void);
RF_ConfigSet_t *rf_create_auto_sets(RF_AutoConfig_t *);
static int rf_does_it_fit(RF_ConfigSet_t *,RF_AutoConfig_t *);
-static int rf_reasonable_label(RF_ComponentLabel_t *, uint64_t);
+int rf_reasonable_label(RF_ComponentLabel_t *, uint64_t);
void rf_create_configuration(RF_AutoConfig_t *,RF_Config_t *, RF_Raid_t *);
int rf_set_autoconfig(RF_Raid_t *, int);
int rf_set_rootpartition(RF_Raid_t *, int);
@@ -3132,7 +3132,7 @@ rf_find_raid_components(void)
}
-static int
+int
rf_reasonable_label(RF_ComponentLabel_t *clabel, uint64_t numsecs)
{
@@ -3157,7 +3157,8 @@ rf_reasonable_label(RF_ComponentLabel_t *clabel, uint64_t numsecs)
* label looks reasonable enough...
* let's make sure it has no old garbage.
*/
- rf_fix_old_label_size(clabel, numsecs);
+ if (numsecs)
+ rf_fix_old_label_size(clabel, numsecs);
return(1);
}
return(0);