loop: don't allow deleting an unspecified loop device

Passing a negative index to loop_lookup while return any unbound device.
Doing that for a delete does not make much sense, so add check to
explicitly reject that case.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20210623145908.92973-8-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Christoph Hellwig 2021-06-23 16:59:06 +02:00 коммит произвёл Jens Axboe
Родитель 18d1f200b3
Коммит e5d66a1032
1 изменённых файлов: 5 добавлений и 0 удалений

Просмотреть файл

@ -2404,6 +2404,11 @@ static int loop_control_remove(int idx)
{
struct loop_device *lo;
int ret;
if (idx < 0) {
pr_warn("deleting an unspecified loop device is not supported.\n");
return -EINVAL;
}
ret = mutex_lock_killable(&loop_ctl_mutex);
if (ret)