Skip to contentSkip to conversation

bcache: fix calling ida_simple_remove() withincorrectminor

PATCH Coly Li 1 participant 1 message May 8, 2017 1 message not in the archive bcache (block layer cache)

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Coly Li

author
#1 lore raw
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/bcache0 has minor 0

> /dev/bcache1 has minor 16

> /dev/bcache2 has minor 32

My 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