Skip to contentSkip to conversation

s390x/sclp: pv: only copy the original SCCB buffer

PATCH Applied Christian Borntraeger 5 participants 6 messages Aug 14 – Aug 27

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390x/sclp: pv: only copy the original SCCB buffer

From: Christian Borntraeger <[email protected]>

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")
---
 hw/s390x/sclp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/s390x/sclp.c +1 -1
index 3c8cb164888..b452f2ce54d 100644
@@ -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;
 }
Signature · 1 line
2.55.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Christian Borntraeger

From: Christian Borntraeger <[email protected]>

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.

Quoted 5 lines
Fixes 0f73c5b30b8b ("s390x: protvirt: SCLP interpretation")
---
  hw/s390x/sclp.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by on v1 1/1
#2 lore raw
In reply to Christian Borntraeger
Quoted 10 lines · Christian Borntraeger

From: Christian Borntraeger <[email protected]>

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.

Quoted 6 lines

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")
Applied
#3 lore raw
In reply to Christian Borntraeger
Quoted 14 lines · Christian Borntraeger

From: Christian Borntraeger <[email protected]>

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.

Quoted 5 lines
Fixes 0f73c5b30b8b ("s390x: protvirt: SCLP interpretation")
---
  hw/s390x/sclp.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks! Applied for 11.2

#4 lore raw
Quoted 13 lines · Eric Farman
Quoted 10 lines · Christian Borntraeger

From: Christian Borntraeger <[email protected]>

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.

Quoted 4 lines
Quoted 4 lines

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.

Quoted 8 lines
Quoted 5 lines
Fixes 0f73c5b30b8b ("s390x: protvirt: SCLP interpretation")

---
  hw/s390x/sclp.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks! Applied for 11.2

#5 lore raw
In reply to Christian Borntraeger
Quoted 14 lines · Christian Borntraeger

From: Christian Borntraeger <[email protected]>

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.

Quoted 5 lines
Fixes 0f73c5b30b8b ("s390x: protvirt: SCLP interpretation")
---
  hw/s390x/sclp.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

I'm picking this one up for the currently active stable qemu series. Please let me know if I shouldn't.

Thanks,

/mjt