All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: check minor range in device_add_disk()
@ 2021-12-17 14:51 Tetsuo Handa
  2021-12-21 16:19 ` Christoph Hellwig
  2021-12-21 16:34 ` Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: Tetsuo Handa @ 2021-12-17 14:51 UTC (permalink / raw)
  To: linux-block

ioctl(fd, LOOP_CTL_ADD, 1048576) causes

  sysfs: cannot create duplicate filename '/dev/block/7:0'

message because such request is treated as if ioctl(fd, LOOP_CTL_ADD, 0)
due to MINORMASK == 1048575. Verify that all minor numbers for that device
fit in the minor range.

Reported-by: wangyangbo <wangyangbo@uniontech.com>
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
 block/genhd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/block/genhd.c b/block/genhd.c
index 30362aeacac4..b6a278f54f34 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -425,6 +425,8 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk,
 				DISK_MAX_PARTS);
 			disk->minors = DISK_MAX_PARTS;
 		}
+		if (disk->first_minor + disk->minors > MINORMASK + 1)
+			return -EINVAL;
 	} else {
 		if (WARN_ON(disk->minors))
 			return -EINVAL;
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] block: check minor range in device_add_disk()
  2021-12-17 14:51 [PATCH] block: check minor range in device_add_disk() Tetsuo Handa
@ 2021-12-21 16:19 ` Christoph Hellwig
  2021-12-21 16:34 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2021-12-21 16:19 UTC (permalink / raw)
  To: Tetsuo Handa; +Cc: linux-block

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] block: check minor range in device_add_disk()
  2021-12-17 14:51 [PATCH] block: check minor range in device_add_disk() Tetsuo Handa
  2021-12-21 16:19 ` Christoph Hellwig
@ 2021-12-21 16:34 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2021-12-21 16:34 UTC (permalink / raw)
  To: linux-block, Tetsuo Handa

On Fri, 17 Dec 2021 23:51:25 +0900, Tetsuo Handa wrote:
> ioctl(fd, LOOP_CTL_ADD, 1048576) causes
> 
>   sysfs: cannot create duplicate filename '/dev/block/7:0'
> 
> message because such request is treated as if ioctl(fd, LOOP_CTL_ADD, 0)
> due to MINORMASK == 1048575. Verify that all minor numbers for that device
> fit in the minor range.
> 
> [...]

Applied, thanks!

[1/1] block: check minor range in device_add_disk()
      commit: e338924bd05d6e71574bc13e310c89e10e49a8a5

Best regards,
-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-12-21 16:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-17 14:51 [PATCH] block: check minor range in device_add_disk() Tetsuo Handa
2021-12-21 16:19 ` Christoph Hellwig
2021-12-21 16:34 ` Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.