lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <509218be-9564-7b25-9d56-cab752abdaa4@linux.ibm.com>
Date:   Mon, 10 May 2021 13:22:06 -0400
From:   Tony Krowiak <akrowiak@...ux.ibm.com>
To:     Christian Borntraeger <borntraeger@...ibm.com>,
        linux-s390@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:     cohuck@...hat.com, pasic@...ux.vnet.ibm.com, jjherne@...ux.ibm.com,
        jgg@...dia.com, alex.williamson@...hat.com, kwankhede@...dia.com,
        stable@...r.kernel.org, Tony Krowiak <akrowiak@...y.rr.com>
Subject: Re: [PATCH] s390/vfio-ap: fix memory leak in mdev remove callback



On 5/5/21 1:44 PM, Christian Borntraeger wrote:
>
>
> On 05.05.21 19:28, Tony Krowiak wrote:
>> The mdev remove callback for the vfio_ap device driver bails out with
>> -EBUSY if the mdev is in use by a KVM guest. The intended purpose was
>> to prevent the mdev from being removed while in use; however, 
>> returning a
>> non-zero rc does not prevent removal. This could result in a memory leak
>> of the resources allocated when the mdev was created. In addition, the
>> KVM guest will still have access to the AP devices assigned to the mdev
>> even though the mdev no longer exists.
>>
>> To prevent this scenario, cleanup will be done - including unplugging 
>> the
>> AP adapters, domains and control domains - regardless of whether the 
>> mdev
>> is in use by a KVM guest or not.
> [...]
>>   static int vfio_ap_mdev_create(struct mdev_device *mdev)
>>   {
>>       struct ap_matrix_mdev *matrix_mdev;
>> @@ -366,16 +392,9 @@ static int vfio_ap_mdev_remove(struct 
>> mdev_device *mdev)
>>       struct ap_matrix_mdev *matrix_mdev = mdev_get_drvdata(mdev);
>>         mutex_lock(&matrix_dev->lock);
>> -
>> -    /*
>> -     * If the KVM pointer is in flux or the guest is running, disallow
>> -     * un-assignment of control domain.
>> -     */
>> -    if (matrix_mdev->kvm_busy || matrix_mdev->kvm) {
>> -        mutex_unlock(&matrix_dev->lock);
>> -        return -EBUSY;
>> -    }
>> -
>> +    WARN(vfio_ap_mdev_has_crycb(matrix_mdev),
>> +         "Removing mdev leaves KVM guest without any crypto devices");
>> +    vfio_ap_mdev_clear_apcb(matrix_mdev);
>
> Triggering a kernel warning due to an administrative task is not good.
> Can't you simply clear the crycb? Maybe do a printk, but not a WARN.

I'll take the warning out.

>
>>       vfio_ap_mdev_reset_queues(mdev);
>>       list_del(&matrix_mdev->node);
>>       kfree(matrix_mdev);
>>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ