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-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200721105239.8270-4-mlevitsk@redhat.com>
Date:   Tue, 21 Jul 2020 13:52:32 +0300
From:   Maxim Levitsky <mlevitsk@...hat.com>
To:     linux-kernel@...r.kernel.org
Cc:     Keith Busch <kbusch@...nel.org>,
        Josef Bacik <josef@...icpanda.com>,
        linux-block@...r.kernel.org (open list:BLOCK LAYER),
        Sagi Grimberg <sagi@...mberg.me>, Jens Axboe <axboe@...nel.dk>,
        linux-nvme@...ts.infradead.org (open list:NVM EXPRESS DRIVER),
        linux-scsi@...r.kernel.org (open list:SCSI CDROM DRIVER),
        Tejun Heo <tj@...nel.org>,
        Bart Van Assche <bvanassche@....org>,
        "Martin K. Petersen" <martin.petersen@...cle.com>,
        Damien Le Moal <damien.lemoal@....com>,
        Jason Wang <jasowang@...hat.com>,
        Maxim Levitsky <maximlevitsky@...il.com>,
        Stefan Hajnoczi <stefanha@...hat.com>,
        Colin Ian King <colin.king@...onical.com>,
        "Michael S. Tsirkin" <mst@...hat.com>,
        Paolo Bonzini <pbonzini@...hat.com>,
        Ulf Hansson <ulf.hansson@...aro.org>,
        Ajay Joshi <ajay.joshi@....com>,
        Ming Lei <ming.lei@...hat.com>,
        linux-mmc@...r.kernel.org (open list:SONY MEMORYSTICK SUBSYSTEM),
        Christoph Hellwig <hch@....de>,
        Satya Tangirala <satyat@...gle.com>,
        nbd@...er.debian.org (open list:NETWORK BLOCK DEVICE (NBD)),
        Hou Tao <houtao1@...wei.com>, Jens Axboe <axboe@...com>,
        virtualization@...ts.linux-foundation.org (open list:VIRTIO CORE AND
        NET DRIVERS), "James E.J. Bottomley" <jejb@...ux.ibm.com>,
        Alex Dubov <oakad@...oo.com>,
        Maxim Levitsky <mlevitsk@...hat.com>
Subject: [PATCH 03/10] block: loop: use blk_is_valid_logical_block_size

This allows to remove loop's own check for supported block size

Signed-off-by: Maxim Levitsky <mlevitsk@...hat.com>
---
 drivers/block/loop.c | 23 +++++------------------
 1 file changed, 5 insertions(+), 18 deletions(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 475e1a738560d..9984c8f824271 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -228,19 +228,6 @@ static void __loop_update_dio(struct loop_device *lo, bool dio)
 		blk_mq_unfreeze_queue(lo->lo_queue);
 }
 
-/**
- * loop_validate_block_size() - validates the passed in block size
- * @bsize: size to validate
- */
-static int
-loop_validate_block_size(unsigned short bsize)
-{
-	if (bsize < 512 || bsize > PAGE_SIZE || !is_power_of_2(bsize))
-		return -EINVAL;
-
-	return 0;
-}
-
 /**
  * loop_set_size() - sets device size and notifies userspace
  * @lo: struct loop_device to set the size for
@@ -1119,9 +1106,10 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
 	}
 
 	if (config->block_size) {
-		error = loop_validate_block_size(config->block_size);
-		if (error)
+		if (!blk_is_valid_logical_block_size(config->block_size)) {
+			error = -EINVAL;
 			goto out_unlock;
+		}
 	}
 
 	error = loop_set_status_from_info(lo, &config->info);
@@ -1607,9 +1595,8 @@ static int loop_set_block_size(struct loop_device *lo, unsigned long arg)
 	if (lo->lo_state != Lo_bound)
 		return -ENXIO;
 
-	err = loop_validate_block_size(arg);
-	if (err)
-		return err;
+	if (!blk_is_valid_logical_block_size(arg))
+		return -EINVAL;
 
 	if (lo->lo_queue->limits.logical_block_size == arg)
 		return 0;
-- 
2.26.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ