lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231124030525.31426-1-wegao@suse.com>
Date:   Thu, 23 Nov 2023 22:05:25 -0500
From:   Wei Gao <wegao@...e.com>
To:     axboe@...nel.dk, dlemoal@...nel.org, hare@...e.de, hch@....de,
        niklas.cassel@....com, martin.petersen@...cle.com,
        linux-block@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:     Wei Gao <wegao@...e.com>
Subject: [PATCH v1] block: ioprio: Fix ioprio_check_cap() validation logic

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@...e.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ