Commit 648bb72a authored by Zhang Wensheng's avatar Zhang Wensheng Committed by Zheng Zengkai
Browse files

nbd: fix possible overflow on 'first_minor' in nbd_dev_add()

hulk inclusion
category: bugfix
bugzilla: 186386, https://gitee.com/openeuler/kernel/issues/I520OX


CVE: NA
backport: openEuler-22.03-LTS

--------------------------------

When 'index' is a big numbers, it may become negative which forced
to 'int'. then 'index << part_shift' might overflow to a positive
value that is not greater than '0xfffff', then sysfs might complains
about duplicate creation. Because of this, move the 'index' judgment
to the front will fix it and be better.

Fixes: b0d9111a ("nbd: use an idr to keep track of nbd devices")
Signed-off-by: default avatarZhang Wensheng <zhangwensheng5@huawei.com>
Reviewed-by: default avatarJason Yan <yanaijie@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent da4cb346
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment