Skip to contentSkip to conversation

DM RAID: Fix comparison of index and quantity for "rebuild" parameter

PATCH Applied Jonathan Brassow 2 participants 2 messages Sep 5, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 DM RAID: Fix comparison of index and quantity for "rebuild" parameter

DM RAID: Fix comparison of index and quantity for "rebuild" parameter

The "rebuild" parameter takes an index argument that starts counting from zero. The conditional used to validate the index was using '>' rather than '>=', leaving the door open for an index value that would be 1 too large.

drivers/md/dm-raid.c +1 -1
Index: linux-upstream/drivers/md/dm-raid.c
===================================================================
@@ -539,7 +539,7 @@ static int parse_raid_params(struct raid
 
 		/* Parameters that take a numeric value are checked here */
 		if (!strcasecmp(key, "rebuild")) {
-			if (value > rs->md.raid_disks) {
+			if (value >= rs->md.raid_disks) {
 				rs->ti->error = "Invalid rebuild index given";
 				return -EINVAL;
 			}
Applied
#1 lore raw
Quoted 15 lines · On Wed, 05 Sep 2012 10:53:20 -0500 Jonathan Brassow <[email protected]> wrote:

DM RAID: Fix comparison of index and quantity for "rebuild" parameter

The "rebuild" parameter takes an index argument that starts counting from zero. The conditional used to validate the index was using '>' rather than '>=', leaving the door open for an index value that would be 1 too large.

Index: linux-upstream/drivers/md/dm-raid.c
===================================================================

drivers/md/dm-raid.c static int parse_raid_params(struct raid · line 545

Quoted 8 lines
drivers/md/dm-raid.c +1 -1
@@ -539,7 +539,7 @@ static int parse_raid_params(struct raid
 
 		/* Parameters that take a numeric value are checked here */
 		if (!strcasecmp(key, "rebuild")) {
-			if (value > rs->md.raid_disks) {
+			if (value >= rs->md.raid_disks) {
 				rs->ti->error = "Invalid rebuild index given";
 				return -EINVAL;
 			}

Applied, thanks.

NeilBrown