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:	Fri, 27 May 2011 08:59:31 -0400
From:	Paul Clements <paul.clements@...sios.com>
To:	Namhyung Kim <namhyung@...il.com>
Cc:	Jens Axboe <axboe@...nel.dk>, linux-kernel@...r.kernel.org,
	Laurent Vivier <Laurent.Vivier@...l.net>
Subject: Re: [PATCH 3/3] nbd: adjust 'max_part' according to part_shift

On Fri, May 27, 2011 at 2:00 AM, Namhyung Kim <namhyung@...il.com> wrote:
> The 'max_part' parameter determines how many partitions are supported
> on each nbd device. However the actual number can be changed to the
> power of 2 minus 1 form during the module initialization as
> alloc_disk() is called with (1 << part_shift) for some reason.
>
> So adjust 'max_part' also at least for consistency with loop and brd.
> It is exported via sysfs already, and a user should check this value
> after module loading if [s]he wants to use that number correctly
> (i.e. fdisk or something).
>
> Signed-off-by: Namhyung Kim <namhyung@...il.com>
> Cc: Laurent Vivier <Laurent.Vivier@...l.net>
> Cc: Paul Clements <Paul.Clements@...eleye.com>

Sure, looks good.

Thanks,
Paul

> ---
>  drivers/block/nbd.c |   13 ++++++++++++-
>  1 files changed, 12 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
> index fdee7567fd15..f533f3375e24 100644
> --- a/drivers/block/nbd.c
> +++ b/drivers/block/nbd.c
> @@ -754,9 +754,20 @@ static int __init nbd_init(void)
>                return -ENOMEM;
>
>        part_shift = 0;
> -       if (max_part > 0)
> +       if (max_part > 0) {
>                part_shift = fls(max_part);
>
> +               /*
> +                * Adjust max_part according to part_shift as it is exported
> +                * to user space so that user can know the max number of
> +                * partition kernel should be able to manage.
> +                *
> +                * Note that -1 is required because partition 0 is reserved
> +                * for the whole disk.
> +                */
> +               max_part = (1UL << part_shift) - 1;
> +       }
> +
>        if ((1UL << part_shift) > DISK_MAX_PARTS)
>                return -EINVAL;
>
> --
> 1.7.5.2
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ