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: <CY4PR04MB3751EED308BB3AE6E028E3DFE7780@CY4PR04MB3751.namprd04.prod.outlook.com>
Date:   Tue, 21 Jul 2020 11:09:15 +0000
From:   Damien Le Moal <Damien.LeMoal@....com>
To:     Maxim Levitsky <mlevitsk@...hat.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
CC:     Keith Busch <kbusch@...nel.org>,
        Josef Bacik <josef@...icpanda.com>,
        "open list:BLOCK LAYER" <linux-block@...r.kernel.org>,
        Sagi Grimberg <sagi@...mberg.me>, Jens Axboe <axboe@...nel.dk>,
        "open list:NVM EXPRESS DRIVER" <linux-nvme@...ts.infradead.org>,
        "open list:SCSI CDROM DRIVER" <linux-scsi@...r.kernel.org>,
        Tejun Heo <tj@...nel.org>,
        Bart Van Assche <bvanassche@....org>,
        "Martin K. Petersen" <martin.petersen@...cle.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>,
        "open list:SONY MEMORYSTICK SUBSYSTEM" <linux-mmc@...r.kernel.org>,
        Christoph Hellwig <hch@....de>,
        Satya Tangirala <satyat@...gle.com>,
        "open list:NETWORK BLOCK DEVICE (NBD)" <nbd@...er.debian.org>,
        Hou Tao <houtao1@...wei.com>, Jens Axboe <axboe@...com>,
        "open list:VIRTIO CORE AND NET DRIVERS" 
        <virtualization@...ts.linux-foundation.org>,
        "James E.J. Bottomley" <jejb@...ux.ibm.com>,
        Alex Dubov <oakad@...oo.com>
Subject: Re: [PATCH 04/10] block: nbd: use blk_is_valid_logical_block_size

On 2020/07/21 19:54, Maxim Levitsky wrote:
> This allows to remove nbd's own check for valid block size
> 
> Signed-off-by: Maxim Levitsky <mlevitsk@...hat.com>
> ---
>  drivers/block/nbd.c | 12 ++----------
>  1 file changed, 2 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
> index ce7e9f223b20b..2cd9c4e824f8b 100644
> --- a/drivers/block/nbd.c
> +++ b/drivers/block/nbd.c
> @@ -1347,14 +1347,6 @@ static void nbd_clear_sock_ioctl(struct nbd_device *nbd,
>  		nbd_config_put(nbd);
>  }
>  
> -static bool nbd_is_valid_blksize(unsigned long blksize)
> -{
> -	if (!blksize || !is_power_of_2(blksize) || blksize < 512 ||
> -	    blksize > PAGE_SIZE)
> -		return false;
> -	return true;
> -}
> -
>  static void nbd_set_cmd_timeout(struct nbd_device *nbd, u64 timeout)
>  {
>  	nbd->tag_set.timeout = timeout * HZ;
> @@ -1379,7 +1371,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
>  	case NBD_SET_BLKSIZE:
>  		if (!arg)
>  			arg = NBD_DEF_BLKSIZE;
> -		if (!nbd_is_valid_blksize(arg))
> +		if (!blk_is_valid_logical_block_size(arg))
>  			return -EINVAL;
>  		nbd_size_set(nbd, arg,
>  			     div_s64(config->bytesize, arg));
> @@ -1811,7 +1803,7 @@ static int nbd_genl_size_set(struct genl_info *info, struct nbd_device *nbd)
>  		bsize = nla_get_u64(info->attrs[NBD_ATTR_BLOCK_SIZE_BYTES]);
>  		if (!bsize)
>  			bsize = NBD_DEF_BLKSIZE;
> -		if (!nbd_is_valid_blksize(bsize)) {
> +		if (!blk_is_valid_logical_block_size(bsize)) {
>  			printk(KERN_ERR "Invalid block size %llu\n", bsize);
>  			return -EINVAL;
>  		}
> 

Looks good to me.

Reviewed-by: Damien Le Moal <damien.lemoal@....com>

-- 
Damien Le Moal
Western Digital Research

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ