projects
/
linux.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
8928051
)
block: check minor range in device_add_disk()
author
Tetsuo Handa
<penguin-kernel@i-love.sakura.ne.jp>
Fri, 17 Dec 2021 14:51:25 +0000
(23:51 +0900)
committer
Greg Kroah-Hartman
<gregkh@linuxfoundation.org>
Thu, 27 Jan 2022 10:04:48 +0000
(11:04 +0100)
[ Upstream commit
e338924bd05d6e71574bc13e310c89e10e49a8a5
]
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link:
https://lore.kernel.org/r/b1b19379-23ee-5379-0eb5-94bf5f79f1b4@i-love.sakura.ne.jp
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
block/genhd.c
patch
|
blob
|
history
diff --git
a/block/genhd.c
b/block/genhd.c
index 22f899615801ca92d2b4953ea2fab3068a935550..de789d1a1e3d2d7b7b377ec293ec47e032a16c98 100644
(file)
--- a/
block/genhd.c
+++ b/
block/genhd.c
@@
-420,6
+420,8
@@
int 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;