All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Krowiak <akrowiak@linux.ibm.com>
To: Halil Pasic <pasic@linux.ibm.com>
Cc: Cornelia Huck <cohuck@redhat.com>,
	linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org,
	kvm@vger.kernel.org, stable@vger.kernel.org,
	borntraeger@de.ibm.com, kwankhede@nvidia.com,
	pbonzini@redhat.com, alex.williamson@redhat.com,
	pasic@linux.vnet.ibm.com
Subject: Re: [PATCH 1/1] s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks
Date: Thu, 11 Feb 2021 14:18:42 -0500	[thread overview]
Message-ID: <39ee96d0-1a5a-ec4b-4816-2caf619d47be@linux.ibm.com> (raw)
In-Reply-To: <20210211174750.24d91a65.pasic@linux.ibm.com>



On 2/11/21 11:47 AM, Halil Pasic wrote:
> On Thu, 11 Feb 2021 09:21:26 -0500
> Tony Krowiak <akrowiak@linux.ibm.com> wrote:
>
>> Yes, it makes sense. I guess I didn't look closely at your
>> suggestion when I said it was exactly what I implemented
>> after agreeing with Connie. I had a slight difference in
>> my implementation:
>>
>> static void vfio_ap_mdev_unset_kvm(struct ap_matrix_mdev *matrix_mdev)
>> {
>>       struct kvm *kvm;
>>
>>       mutex_lock(&matrix_dev->lock);
>>
>>       if (matrix_mdev->kvm) {
>>           kvm = matrix_mdev->kvm;
>>           mutex_unlock(&matrix_dev->lock);
> The problem with this one is that as soon as we drop
> the lock here, another thread can in theory execute
> the critical section below, which drops our reference
> to kvm via kvm_put_kvm(kvm). Thus when we enter
> kvm_arch_crypto_clear_mask(), even if we are guaranteed
> to have a non-null pointer, the pointee is not guaranteed
> to be around. So like Connie suggested, you better take
> another reference to kvm in the first critical section.

Sure.

>
> Regards,
> Halil
>
>>           kvm_arch_crypto_clear_masks(kvm);
>>           mutex_lock(&matrix_dev->lock);
>>           kvm->arch.crypto.pqap_hook = NULL;
>>           vfio_ap_mdev_reset_queues(matrix_mdev->mdev);
>>           matrix_mdev->kvm = NULL;
>>           kvm_put_kvm(kvm);
>>       }
>>
>>       mutex_unlock(&matrix_dev->lock);
>> }


  reply	other threads:[~2021-02-11 19:21 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-09 19:48 [PATCH 0/1] fix circular lockdep when staring SE guest Tony Krowiak
2021-02-09 19:48 ` [PATCH 1/1] s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks Tony Krowiak
2021-02-10 10:53   ` Cornelia Huck
2021-02-10 15:24     ` Halil Pasic
2021-02-10 15:32       ` Halil Pasic
2021-02-10 22:05         ` Tony Krowiak
2021-02-10 22:46           ` Halil Pasic
2021-02-11 14:21             ` Tony Krowiak
2021-02-11 16:47               ` Halil Pasic
2021-02-11 19:18                 ` Tony Krowiak [this message]
2021-02-10 22:03       ` Tony Krowiak
2021-02-10 20:34     ` Tony Krowiak
2021-02-11 12:23       ` Cornelia Huck
2021-02-11 14:38         ` Tony Krowiak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=39ee96d0-1a5a-ec4b-4816-2caf619d47be@linux.ibm.com \
    --to=akrowiak@linux.ibm.com \
    --cc=alex.williamson@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=kwankhede@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=pasic@linux.ibm.com \
    --cc=pasic@linux.vnet.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.