All of lore.kernel.org
 help / color / mirror / Atom feed
From: Md Haris Iqbal <haris.iqbal@linux.dev>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, Jonathan Corbet <corbet@lwn.net>,
	Md Haris Iqbal <haris.iqbal@linux.dev>,
	Christoph Hellwig <hch@lst.de>
Subject: [RFC for-next 1/3] block: reject unknown status tags in error injection rules
Date: Thu, 27 Aug 2026 02:01:13 +0200	[thread overview]
Message-ID: <20260827000115.128093-2-haris.iqbal@linux.dev> (raw)
In-Reply-To: <20260827000115.128093-1-haris.iqbal@linux.dev>

An unknown status tag leaves *status at BLK_STS_OK, which
error_inject_add() then rejects.  Fail in match_status() instead, so that
rejecting a bad tag does not rely on BLK_STS_OK being invalid for a rule.

For a single status= this does not change behaviour: an unknown tag still
fails the write with -EINVAL.  A repeated status= where an invalid tag
comes first is now rejected instead of being overridden by the later one.

Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Md Haris Iqbal <haris.iqbal@linux.dev>
---
 block/error-injection.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/block/error-injection.c b/block/error-injection.c
index e14bc4b723ef..47cdd8973adc 100644
--- a/block/error-injection.c
+++ b/block/error-injection.c
@@ -171,15 +171,18 @@ static int match_op(substring_t *args, enum req_op *op)
 static int match_status(substring_t *args, blk_status_t *status)
 {
 	const char *tag;
+	int ret = 0;
 
 	tag = match_strdup(args);
 	if (!tag)
 		return -ENOMEM;
 	*status = tag_to_blk_status(tag);
-	if (!*status)
+	if (!*status) {
 		pr_warn("invalid status '%s'\n", tag);
+		ret = -EINVAL;
+	}
 	kfree(tag);
-	return 0;
+	return ret;
 }
 
 static ssize_t blk_error_injection_parse_options(struct gendisk *disk,
-- 
2.53.0


  reply	other threads:[~2026-08-27  0:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-27  0:01 [RFC for-next 0/3] block: delay support for error injection Md Haris Iqbal
2026-08-27  0:01 ` Md Haris Iqbal [this message]
2026-08-27  0:01 ` [RFC for-next 2/3] block: allow error injection rules to delay bios Md Haris Iqbal
2026-08-27 13:02   ` Haris Iqbal
2026-08-27 22:44     ` Haris Iqbal
2026-08-27  0:01 ` [RFC for-next 3/3] Documentation: block: document error injection delays Md Haris Iqbal
2026-08-27  3:49 ` [RFC for-next 0/3] block: delay support for error injection Keith Busch
2026-08-27 22:40   ` Haris Iqbal

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=20260827000115.128093-2-haris.iqbal@linux.dev \
    --to=haris.iqbal@linux.dev \
    --cc=axboe@kernel.dk \
    --cc=corbet@lwn.net \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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.