Re: [PATCH] block: Fix minor range check in device_add_disk()

From: zhongjinghua
Date: Thu Oct 26 2023 - 04:52:57 EST



在 2023/10/25 18:06, Tetsuo Handa 写道:
On 2023/10/25 17:46, Zhong Jinghua wrote:
Checks added in patch:
commit e338924bd05d ("block: check minor range in device_add_disk()")
ignore the problem of first_minore < 0 and disk->minors < 0.
What is the problem of first_minor < 0 or disk->minors < 0 ?
Are negative values legal/illegal ?

These two values are used as the secondary device number and the maximum number of partitions, which is illegal if negative. Then first_minore and disk->minors are signed numbers, and the sum may be less than MINORMASK to bypass the check.