From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Halil Pasic <pasic@linux.ibm.com>, Tony Krowiak <akrowiak@linux.ibm.com>
Cc: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org,
cohuck@redhat.com, pasic@linux.vnet.ibm.com,
jjherne@linux.ibm.com, jgg@nvidia.com,
alex.williamson@redhat.com, kwankhede@nvidia.com,
stable@vger.kernel.org, Tony Krowiak <akrowiak@stny.rr.com>
Subject: Re: [PATCH v2] s390/vfio-ap: fix memory leak in mdev remove callback
Date: Tue, 18 May 2021 11:30:27 +0200 [thread overview]
Message-ID: <966a60ad-bdde-68d0-ae2f-06121c6ad970@de.ibm.com> (raw)
In-Reply-To: <20210517211030.368ca64b.pasic@linux.ibm.com>
On 17.05.21 21:10, Halil Pasic wrote:
> On Mon, 17 May 2021 09:37:42 -0400
> Tony Krowiak <akrowiak@linux.ibm.com> wrote:
>
>>>
>>> Because of this, I don't think the rest of your argument is valid.
>>
>> Okay, so your concern is that between the point in time the
>> vcpu->kvm->arch.crypto.pqap_hook pointer is checked in
>> priv.c and the point in time the handle_pqap() function
>> in vfio_ap_ops.c is called, the memory allocated for the
>> matrix_mdev containing the struct kvm_s390_module_hook
>> may get freed, thus rendering the function pointer invalid.
>> While not impossible, that seems extremely unlikely to
>> happen. Can you articulate a scenario where that could
>> even occur?
>
> Malicious userspace. We tend to do the pqap aqic just once
> in the guest right after the queue is detected. I do agree
> it ain't very likely to happen during normal operation. But why are
> you asking?
Would it help, if the code in priv.c would read the hook once
and then only work on the copy? We could protect that with rcu
and do a synchronize rcu in vfio_ap_mdev_unset_kvm after
unsetting the pointer?
>
> I'm not sure I understood correctly what kind of a scenario are
> you asking for. PQAP AQIC and mdev remove are independent
> events originated in userspace, so AFAIK we may not assume
> that the execution of two won't overlap, nor are we allowed
> to make assumptions on how does the execution of these two
> overlap (except for the things we explicitly ensure -- e.g.
> some parts are made mutually exclusive using the matrix_dev->lock
> lock).
>
> Regards,
> Halil
>
next prev parent reply other threads:[~2021-05-18 9:30 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-10 21:48 Tony Krowiak
2021-05-10 21:56 ` Tony Krowiak
2021-05-12 10:35 ` Cornelia Huck
2021-05-12 12:41 ` Jason Gunthorpe
2021-05-12 15:32 ` Christian Borntraeger
2021-05-12 16:50 ` Jason Gunthorpe
2021-05-13 14:19 ` Tony Krowiak
2021-05-13 14:18 ` Tony Krowiak
2021-05-13 17:25 ` Jason Gunthorpe
2021-05-13 17:32 ` Halil Pasic
2021-05-13 17:34 ` Jason Gunthorpe
2021-05-12 16:49 ` Christian Borntraeger
2021-05-12 18:35 ` Halil Pasic
2021-05-13 14:35 ` Tony Krowiak
2021-05-13 17:45 ` Halil Pasic
2021-05-13 19:23 ` Tony Krowiak
2021-05-14 0:15 ` Halil Pasic
2021-05-17 13:37 ` Tony Krowiak
2021-05-17 19:10 ` Halil Pasic
2021-05-18 9:30 ` Christian Borntraeger [this message]
2021-05-18 13:42 ` Tony Krowiak
2021-05-18 13:59 ` Christian Borntraeger
2021-05-18 15:33 ` Halil Pasic
2021-05-18 17:01 ` Christian Borntraeger
2021-05-18 23:27 ` Halil Pasic
2021-05-19 8:17 ` Christian Borntraeger
2021-05-19 11:22 ` Christian Borntraeger
2021-05-19 12:59 ` Halil Pasic
2021-05-19 13:02 ` Jason Gunthorpe
2021-05-19 11:25 ` Halil Pasic
2021-05-18 18:14 ` Tony Krowiak
2021-05-18 18:22 ` Christian Borntraeger
2021-05-18 18:40 ` Tony Krowiak
2021-05-18 13:41 ` 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=966a60ad-bdde-68d0-ae2f-06121c6ad970@de.ibm.com \
--to=borntraeger@de.ibm.com \
--cc=akrowiak@linux.ibm.com \
--cc=akrowiak@stny.rr.com \
--cc=alex.williamson@redhat.com \
--cc=cohuck@redhat.com \
--cc=jgg@nvidia.com \
--cc=jjherne@linux.ibm.com \
--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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®