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: <f098fc11-d328-8130-bab9-bf38e18a7400@linux.ibm.com>
Date:   Mon, 28 Jun 2021 14:27:26 -0400
From:   Tony Krowiak <akrowiak@...ux.ibm.com>
To:     Jason Gunthorpe <jgg@...dia.com>
Cc:     linux-s390@...r.kernel.org, linux-kernel@...r.kernel.org,
        borntraeger@...ibm.com, cohuck@...hat.com,
        pasic@...ux.vnet.ibm.com, jjherne@...ux.ibm.com,
        alex.williamson@...hat.com, kwankhede@...dia.com,
        frankja@...ux.ibm.com, david@...hat.com, imbrenda@...ux.ibm.com,
        hca@...ux.ibm.com
Subject: Re: [PATCH] s390/vfio-ap: do not use open locks during
 VFIO_GROUP_NOTIFY_SET_KVM notification



On 6/28/21 2:22 PM, Jason Gunthorpe wrote:
> On Mon, Jun 28, 2021 at 02:20:55PM -0400, Tony Krowiak wrote:
>>
>> On 6/28/21 1:34 PM, Jason Gunthorpe wrote:
>>> On Fri, Jun 25, 2021 at 06:07:58PM -0400, Tony Krowiak wrote:
>>>>    static void vfio_ap_mdev_unset_kvm(struct ap_matrix_mdev *matrix_mdev)
>>>>    {
>>>> +	mutex_lock(&matrix_dev->lock);
>>>> +	if ((matrix_mdev->kvm) && (matrix_mdev->kvm->arch.crypto.crycbd)) {
>>>>    		mutex_unlock(&matrix_dev->lock);
>>>> +		down_write(&matrix_mdev->kvm->arch.crypto.pqap_hook_rwsem);
>>>> +		matrix_mdev->kvm->arch.crypto.pqap_hook = NULL;
>>>> +		up_write(&matrix_mdev->kvm->arch.crypto.pqap_hook_rwsem);
>>>> +		kvm_arch_crypto_clear_masks(matrix_mdev->kvm);
>>>>    		mutex_lock(&matrix_dev->lock);
>>>>    		vfio_ap_mdev_reset_queues(matrix_mdev->mdev);
>>>>    		kvm_put_kvm(matrix_mdev->kvm);
>>>>    		matrix_mdev->kvm = NULL;
>>>> +		mutex_unlock(&matrix_dev->lock);
>>>>    	}
>>> Doesn't a flow exit the function with matrix_dev->lock held he

Yes, you are correct. Stupid mistake.

>> How can that happen? What flow?
> When the if isn't taken
>
>>> Write it with 'success oriented flow'
>> I'm not sure what you mean, can you clarify this statement?
> Basically, don't write the bulk of the function under an if statement
>
> mutex_lock(&matrix_dev->lock);
> if (!matrix_mdev->kvm || !matrix_mdev->kvm->arch.crypto.crycbd) {
>      mutex_unlock(&matrix_dev->lock);
>      return;
> }

Sure.

>
> Jason
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ