mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pavel Skripkin <paskripkin@gmail.com>
To: "Yan, Zheng" <ukernel@gmail.com>,
	axboe@kernel.dk, Christoph Hellwig <hch@lst.de>
Cc: "Yan, Zheng" <yanzheng03@kuaishou.com>,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] block: nbd: fix sanity check for first_minor
Date: Sat, 9 Oct 2021 11:46:23 +0300	[thread overview]
Message-ID: <ac132dff-ccde-bb14-9590-50f5b9f076e5@gmail.com> (raw)
In-Reply-To: <20211009053540.95100-1-ukernel@gmail.com>

On 10/9/21 08:35, Yan, Zheng wrote:

+CC Christoph

> From: "Yan, Zheng" <yanzheng03@kuaishou.com>
> 
> Device's minor is a 20-bits number, max value is 0xfffff.
> 
> Fixes: b1a811633f ("block: nbd: add sanity check for first_minor").
> Signed-off-by: "Yan, Zheng" <yanzheng03@kuaishou.com>
> ---
>   drivers/block/nbd.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
> index 1183f7872b71..53cd038c96e9 100644
> --- a/drivers/block/nbd.c
> +++ b/drivers/block/nbd.c
> @@ -1753,7 +1753,7 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs)
>   	 * byte in __device_add_disk().
>   	 */
>   	disk->first_minor = index << part_shift;
> -	if (disk->first_minor > 0xff) {
> +	if (disk->first_minor > MINORMASK) {
>   		err = -EINVAL;
>   		goto out_free_idr;
>   	}
> 

I've looked into what confused me with 0xff and I found that uapi's 
kdev_t.h has following MINOR definition:

#define MINOR(dev)	((dev) & 0xff)


But kernel's kdev_t.h is really allows 20 bit minor number :)

Also, can you, please, fix up comment above this check, since it 
contains info about max minor 0xff and it can confuse readers.




With regards,
Pavel Skripkin

      reply	other threads:[~2021-10-09  8:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-09  5:35 Yan, Zheng
2021-10-09  8:46 ` Pavel Skripkin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ac132dff-ccde-bb14-9590-50f5b9f076e5@gmail.com \
    --to=paskripkin@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ukernel@gmail.com \
    --cc=yanzheng03@kuaishou.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®