Thread (16 messages) 16 messages, 4 authors, 2026-03-24

Re: [PATCH v4 3/4] KVM: s390: avoid kvm_s390_handle_pv() error overwrite

From: Suren Baghdasaryan <surenb@google.com>
Date: 2026-03-23 18:48:19
Also in: linux-mm, linux-s390, linuxppc-dev, lkml

On Mon, Mar 23, 2026 at 10:53 AM Lorenzo Stoakes (Oracle)
[off-list ref] wrote:
On Sat, Mar 21, 2026 at 10:43:07PM -0700, Suren Baghdasaryan wrote:
quoted
If kvm_s390_handle_pv() call fails its error code gets recorded but
execution proceeds as if the call was successful. If the next call to
copy_to_user() fails then the original error is overwritten.
Is that really a big deal though, as you're returning an error in either case?
quoted
The follow-up patch adds fatal signal checks during VMA walk, which
makes it possible for kvm_s390_handle_pv() to return EINTR error.
Without this fix any error including EINTR can be overwritten and
original error will be lost.

Change error handling for kvm_s390_handle_pv() to alter normal flow
once failure happens. This is consistent with how kvm_arch_vm_ioctl
handles errors for other ioctl commands.

Signed-off-by: Suren Baghdasaryan <surenb@google.com>
---
 arch/s390/kvm/kvm-s390.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 3eb60aa932ec..ddad08c0926f 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -2947,6 +2947,8 @@ int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)
              }
              /* must be called without kvm->lock */
              r = kvm_s390_handle_pv(kvm, &args);
+             if (r)
+                     break;
              if (copy_to_user(argp, &args, sizeof(args))) {
Yeah as per Sashiko we probably need to copy_to_user() still.

But in that case, do we even need a change at all? I'm not sure it really
matters which error code terminates things does it?
I agree. I plan to drop this patch from the series (see my former
reply) unless someone tells me otherwise.
quoted
                      r = -EFAULT;
                      break;
--
2.53.0.1018.g2bb0e51243-goog
Thanks, Lorenzo
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help