* [PATCH v2] block: nbd: fix sanity check for first_minor
@ 2021-10-11 2:45 Yan, Zheng
2021-10-11 7:35 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Yan, Zheng @ 2021-10-11 2:45 UTC (permalink / raw)
To: linux-block, linux-kernel; +Cc: axboe, hch, paskripkin, Yan, Zheng
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 | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 1183f7872b71..118039d35468 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1750,10 +1750,10 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs)
/* Too big first_minor can cause duplicate creation of
* sysfs files/links, since first_minor will be truncated to
- * byte in __device_add_disk().
+ * 20-bits number 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;
}
--
2.12.2
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v2] block: nbd: fix sanity check for first_minor
2021-10-11 2:45 [PATCH v2] block: nbd: fix sanity check for first_minor Yan, Zheng
@ 2021-10-11 7:35 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2021-10-11 7:35 UTC (permalink / raw)
To: Yan, Zheng; +Cc: linux-block, linux-kernel, axboe, hch, paskripkin, Yan, Zheng
On Mon, Oct 11, 2021 at 10:45:09AM +0800, Yan, Zheng wrote:
> From: "Yan, Zheng" <yanzheng03@kuaishou.com>
>
> Device's minor is a 20-bits number, max value is 0xfffff.
I'd just drop this check again now that we do have proper error
handling in add_disk.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-11 7:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-11 2:45 [PATCH v2] block: nbd: fix sanity check for first_minor Yan, Zheng
2021-10-11 7:35 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox