From: Wei Gao <wegao@suse.com>
To: axboe@kernel.dk, dlemoal@kernel.org, hare@suse.de, hch@lst.de,
niklas.cassel@wdc.com, martin.petersen@oracle.com,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Wei Gao <wegao@suse.com>
Subject: [PATCH v1] block: ioprio: Fix ioprio_check_cap() validation logic
Date: Thu, 23 Nov 2023 22:05:25 -0500 [thread overview]
Message-ID: <20231124030525.31426-1-wegao@suse.com> (raw)
The current logic "if (level >= IOPRIO_NR_LEVELS)" can not be reached since
level value get from IOPRIO_PRIO_LEVEL ONLY extract lower 3-bits of ioprio.
(IOPRIO_NR_LEVELS=8)
So this trigger LTP test case ioprio_set03 failed, the test case expect
error when set IOPRIO_CLASS_BE prio 8, in current implementation level
value will be 0 and obviously can not return error.
Fixes: eca2040972b4 ("scsi: block: ioprio: Clean up interface definition")
Signed-off-by: Wei Gao <wegao@suse.com>
---
block/ioprio.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/block/ioprio.c b/block/ioprio.c
index b5a942519a79..f83029208f2a 100644
--- a/block/ioprio.c
+++ b/block/ioprio.c
@@ -33,7 +33,7 @@
int ioprio_check_cap(int ioprio)
{
int class = IOPRIO_PRIO_CLASS(ioprio);
- int level = IOPRIO_PRIO_LEVEL(ioprio);
+ int data = IOPRIO_PRIO_DATA(ioprio);
switch (class) {
case IOPRIO_CLASS_RT:
@@ -49,13 +49,13 @@ int ioprio_check_cap(int ioprio)
fallthrough;
/* rt has prio field too */
case IOPRIO_CLASS_BE:
- if (level >= IOPRIO_NR_LEVELS)
+ if (data >= IOPRIO_NR_LEVELS || data < 0)
return -EINVAL;
break;
case IOPRIO_CLASS_IDLE:
break;
case IOPRIO_CLASS_NONE:
- if (level)
+ if (data)
return -EINVAL;
break;
case IOPRIO_CLASS_INVALID:
--
2.34.1
next reply other threads:[~2023-11-24 3:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-24 3:05 Wei Gao [this message]
2023-11-24 5:53 ` [PATCH v1] block: ioprio: Fix ioprio_check_cap() validation logic Damien Le Moal
2023-11-24 14:05 ` Wei Gao
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=20231124030525.31426-1-wegao@suse.com \
--to=wegao@suse.com \
--cc=axboe@kernel.dk \
--cc=dlemoal@kernel.org \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=niklas.cassel@wdc.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox