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]
Date:   Tue, 21 Jul 2020 13:52:34 +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 05/10] block: null: use blk_is_valid_logical_block_size

This slightly changes the behavier of the driver,
when given invalid block size (non power of two, or below 512 bytes),
but shoudn't matter.

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

diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c
index 87b31f9ca362e..e4df4b903b90b 100644
--- a/drivers/block/null_blk_main.c
+++ b/drivers/block/null_blk_main.c
@@ -1684,8 +1684,8 @@ static int null_init_tag_set(struct nullb *nullb, struct blk_mq_tag_set *set)
 
 static int null_validate_conf(struct nullb_device *dev)
 {
-	dev->blocksize = round_down(dev->blocksize, 512);
-	dev->blocksize = clamp_t(unsigned int, dev->blocksize, 512, 4096);
+	if (!blk_is_valid_logical_block_size(dev->blocksize))
+		return -ENODEV;
 
 	if (dev->queue_mode == NULL_Q_MQ && dev->use_per_node_hctx) {
 		if (dev->submit_queues != nr_online_nodes)
@@ -1865,7 +1865,7 @@ static int __init null_init(void)
 	struct nullb *nullb;
 	struct nullb_device *dev;
 
-	if (g_bs > PAGE_SIZE) {
+	if (!blk_is_valid_logical_block_size(g_bs)) {
 		pr_warn("invalid block size\n");
 		pr_warn("defaults block size to %lu\n", PAGE_SIZE);
 		g_bs = PAGE_SIZE;
-- 
2.26.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ