[PATCH] dm unstripe: reject stripe indexes equal to the stripe count

Samuel Moelius <[email protected]>
Newsgroups dev.linux.lists.dm-devel,org.kernel.vger.linux-kernel
Message-ID <20260609003250.1237334.ff865e6f1962.dm-unstripe-stripe-index-off-by-one@trailofbits.com>
dm-unstripe accepts a stripe index that is equal to the number of
configured stripes.  Valid indexes are zero based, so that value is one
past the last stripe.

The out-of-range value can later be used in mapping calculations and
describe a stripe that does not exist.

Reject stripe indexes greater than or equal to the configured stripe
count.

Assisted-by: Codex:gpt-5.5-cyber-preview
Signed-off-by: Samuel Moelius <[email protected]>
---
 drivers/md/dm-unstripe.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm-unstripe.c b/drivers/md/dm-unstripe.c
index bfcbe6bfa71a..b1a8ec69ccad 100644
--- a/drivers/md/dm-unstripe.c
+++ b/drivers/md/dm-unstripe.c
@@ -69,8 +69,8 @@ static int unstripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 		goto err;
 	}
 
-	if (uc->unstripe > uc->stripes && uc->stripes > 1) {
-		ti->error = "Please provide stripe between [0, # of stripes]";
+	if (uc->unstripe >= uc->stripes) {
+		ti->error = "Invalid stripe number";
 		goto err;
 	}
 
-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.