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: <20230627081339.fv76swi3srqdfpra@localhost>
Date:   Tue, 27 Jun 2023 10:13:39 +0200
From:   Pankaj Raghav <p.raghav@...sung.com>
To:     Damien Le Moal <dlemoal@...nel.org>
CC:     Min Li <min15.li@...sung.com>, <axboe@...nel.dk>,
        <willy@...radead.org>, <hch@....de>, <gregkh@...uxfoundation.org>,
        <linux-block@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] block: add check that partition length needs to be
 aligned with block size

On Tue, Jun 27, 2023 at 01:39:26PM +0900, Damien Le Moal wrote:
> > diff --git a/block/ioctl.c b/block/ioctl.c
> > index 3be11941fb2d..c40b382dd58f 100644
> > --- a/block/ioctl.c
> > +++ b/block/ioctl.c
> > @@ -33,14 +33,18 @@ static int blkpg_do_ioctl(struct block_device *bdev,
> >  	if (op == BLKPG_DEL_PARTITION)
> >  		return bdev_del_partition(disk, p.pno);
> >  
> > +	/* check if partition is aligned to blocksize */
> > +	if (p.start & (bdev_logical_block_size(bdev) - 1))
> > +		return -EINVAL;
> > +	/* check if length is aligned to blocksize */
> > +	if (p.length & (bdev_logical_block_size(bdev) - 1))
> > +		return -EINVAL;
> 
> 	long long blksz_mask = bdev_logical_block_size(bdev) - 1;
> 
> 	/* Check that the partition is aligned to the block size */
> 	if ((p.start & blksz_mask) || (p.length & blksz_mask))
> 		return -EINVAL;

A Minor nit on top of your comment:

 	unsigned int blksz = bdev_logical_block_size(bdev);
 
 	/* Check that the partition is aligned to the block size */
 	if (!IS_ALIGNED(p.start, blksz) || !IS_ALIGNED(p.length, blksz))
 		return -EINVAL;

> 
> would be cleaner and avoid the rather redundant comments.
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ