bcache: fix calling ida_simple_remove() withincorrectminor
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 17 lines · On 2017/5/8 下午2:44, [email protected] wrote:
Hello Coly,
> I mean if there are partitions on bcache devices, like
>
/dev/bcache0p1,/dev/bcache0p2.../dev/bcache0p16>
/dev/bcache1p1,/dev/bcache1p2.../dev/bcache0p16>
>
> bcache0 is not the last level to allocate minor number, bcache0p1 is.
> What we should fix might be:
Quoted 8 lines
>
/dev/bcache0has minor 0>
/dev/bcache1has minor 16>
/dev/bcache2has minor 32My patch does not break this. Please review the patch again.
I think I come to understand you, yes your fix makes sense.
In your patch d->disk->first_minor is assigned by IDA_TO_BCACHE_MINORS(minor), which left-shifts minor by 4 bits. So your patch will introduce a potential overflow for device minor number.
MINORMASK is 20 bits, if you call ida_simple_get() like this,
minor = ida_simple_get(&bcache_minor, 0, BCACHE_TO_IDA_MONIRS(MINORMASK
+ 1), GFP_KERNEL);
The overflow should be removed.
I have no more concern about your patch. Nice catch, thank you !
Signature · 1 line
Coly Li