From: Claudio Imbrenda <imbrenda@linux.ibm.com>
To: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>,
Janosch Frank <frankja@linux.ibm.com>,
Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
David Hildenbrand <david@redhat.com>,
Sven Schnelle <svens@linux.ibm.com>,
kvm@vger.kernel.org, linux-s390@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: s390: Fix lockdep issue in vm memop
Date: Tue, 22 Mar 2022 17:15:08 +0100 [thread overview]
Message-ID: <20220322171508.4c0f7ef7@p-imbrenda> (raw)
In-Reply-To: <20220322153204.2637400-1-scgl@linux.ibm.com>
On Tue, 22 Mar 2022 16:32:04 +0100
Janis Schoetterl-Glausch <scgl@linux.ibm.com> wrote:
> Issuing a memop on a protected vm does not make sense,
> neither is the memory readable/writable, nor does it make sense to check
> storage keys. This is why the ioctl will return -EINVAL when it detects
> the vm to be protected. However, in order to ensure that the vm cannot
> become protected during the memop, the kvm->lock would need to be taken
> for the duration of the ioctl. This is also required because
> kvm_s390_pv_is_protected asserts that the lock must be held.
> Instead, don't try to prevent this. If user space enables secure
> execution concurrently with a memop it must accecpt the possibility of
> the memop failing.
> Still check if the vm is currently protected, but without locking and
> consider it a heuristic.
>
> Fixes: ef11c9463ae0 ("KVM: s390: Add vm IOCTL for key checked guest absolute memory access")
> Signed-off-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> ---
> arch/s390/kvm/kvm-s390.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> index ca96f84db2cc..53adbe86a68f 100644
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c
> @@ -2385,7 +2385,16 @@ static int kvm_s390_vm_mem_op(struct kvm *kvm, struct kvm_s390_mem_op *mop)
> return -EINVAL;
> if (mop->size > MEM_OP_MAX_SIZE)
> return -E2BIG;
> - if (kvm_s390_pv_is_protected(kvm))
> + /*
> + * This is technically a heuristic only, if the kvm->lock is not
> + * taken, it is not guaranteed that the vm is/remains non-protected.
> + * This is ok from a kernel perspective, wrongdoing is detected
> + * on the access, -EFAULT is returned and the vm may crash the
> + * next time it accesses the memory in question.
> + * There is no sane usecase to do switching and a memop on two
> + * different CPUs at the same time.
> + */
> + if (kvm_s390_pv_get_handle(kvm))
> return -EINVAL;
> if (mop->flags & KVM_S390_MEMOP_F_SKEY_PROTECTION) {
> if (access_key_invalid(mop->key))
>
> base-commit: c9b8fecddb5bb4b67e351bbaeaa648a6f7456912
next prev parent reply other threads:[~2022-03-22 16:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-22 15:32 [PATCH] KVM: s390: Fix lockdep issue in vm memop Janis Schoetterl-Glausch
2022-03-22 16:15 ` Claudio Imbrenda [this message]
2022-03-23 7:58 ` Janosch Frank
2022-03-23 8:52 ` Janis Schoetterl-Glausch
2022-03-23 8:57 ` Janosch Frank
2022-03-23 9:30 ` Christian Borntraeger
2022-03-23 9:39 ` Janis Schoetterl-Glausch
2022-03-23 9:45 ` Christian Borntraeger
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=20220322171508.4c0f7ef7@p-imbrenda \
--to=imbrenda@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=david@redhat.com \
--cc=frankja@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=scgl@linux.ibm.com \
--cc=svens@linux.ibm.com \
/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