All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] s390x/sclp: pv: only copy the original SCCB buffer
@ 2026-08-14 12:58 Christian Borntraeger
  2026-08-14 17:18 ` Eric Farman
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Christian Borntraeger @ 2026-08-14 12:58 UTC (permalink / raw)
  To: Cornelia Huck
  Cc: qemu-devel, qemu-s390x, David Hildenbrand, Richard Henderson,
	Janosch Frank, Eric Farman, Halil Pasic, Jason Herne,
	Ilya Leoshkevich, Matthew Rosato, Christian Borntraeger

From: Christian Borntraeger <borntraeger@linux.ibm.com>

With variable length and EXTENDED_LENGTH_SCCB, some callbacks might
change the length field. For example read SCP info might write a new
length into the SCCB header. We must not use that new length for the
buffer copy, since the buffer was allocated with the original length.
Only the length field in the work SCCB is changed, to indicate the
"necessary" size. Using the new length reads past the allocation, so
tools like ASAN might detect a buffer overrun.

Secure guests do not have EXTENDED_LENGTH_SCCB, and the ultravisor checks
and sanitizes the length field, so no qemu heap contents are exposed to
the guest and the non pv-path already has the same header.length.

Fixes: 0f73c5b30b8b ("s390x: protvirt: SCLP interpretation")
Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
---
 hw/s390x/sclp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
index 3c8cb164888..b452f2ce54d 100644
--- a/hw/s390x/sclp.c
+++ b/hw/s390x/sclp.c
@@ -287,7 +287,7 @@ int sclp_service_call_protected(S390CPU *cpu, uint64_t sccb, uint32_t code)
     sclp_c->execute(sclp, work_sccb, code);
 out_write:
     s390_cpu_pv_mem_write(env_archcpu(env), 0, work_sccb,
-                          be16_to_cpu(work_sccb->h.length));
+                          be16_to_cpu(header.length));
     sclp_c->service_interrupt(sclp, SCLP_PV_DUMMY_ADDR);
     return 0;
 }
-- 
2.55.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-08-27  5:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-14 12:58 [PATCH] s390x/sclp: pv: only copy the original SCCB buffer Christian Borntraeger
2026-08-14 17:18 ` Eric Farman
2026-08-18 21:07 ` Matthew Rosato
2026-08-19 11:06 ` Eric Farman
2026-08-20  6:35   ` Philippe Mathieu-Daudé
2026-08-27  5:52 ` Michael Tokarev

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.