Skip to contentSkip to conversation

s390x: Fix leak in machine_set_loadparm

PATCH In review Fabiano Rosas 5 participants 9 messages May 9, 2025 – Jun 25, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390x: Fix leak in machine_set_loadparm

ASAN spotted a leaking string in machine_set_loadparm():

Direct leak of 9 byte(s) in 1 object(s) allocated from:

    #0 0x560ffb5bb379 in malloc ../projects/compiler-rt/lib/asan/asan_malloc_linux.cpp:69:3
    #1 0x7f1aca926518 in g_malloc ../glib/gmem.c:106
    #2 0x7f1aca94113e in g_strdup ../glib/gstrfuncs.c:364
    #3 0x560ffc8afbf9 in qobject_input_type_str ../qapi/qobject-input-visitor.c:542:12
    #4 0x560ffc8a80ff in visit_type_str ../qapi/qapi-visit-core.c:349:10
    #5 0x560ffbe6053a in machine_set_loadparm ../hw/s390x/s390-virtio-ccw.c:802:10
    #6 0x560ffc0c5e52 in object_property_set ../qom/object.c:1450:5
    #7 0x560ffc0d4175 in object_property_set_qobject ../qom/qom-qobject.c:28:10
    #8 0x560ffc0c6004 in object_property_set_str ../qom/object.c:1458:15
    #9 0x560ffbe2ae60 in update_machine_ipl_properties ../hw/s390x/ipl.c:569:9
    #10 0x560ffbe2aa65 in s390_ipl_update_diag308 ../hw/s390x/ipl.c:594:5
    #11 0x560ffbdee132 in handle_diag_308 ../target/s390x/diag.c:147:9
    #12 0x560ffbebb956 in helper_diag ../target/s390x/tcg/misc_helper.c:137:9
    #13 0x7f1a3c51c730  (/memfd:tcg-jit (deleted)+0x39730)
---
 hw/s390x/s390-virtio-ccw.c | 1 +
 1 file changed, 1 insertion(+)
hw/s390x/s390-virtio-ccw.c +1 -0
index d5658afed9..744e901db8 100644
@@ -804,6 +804,7 @@ static void machine_set_loadparm(Object *obj, Visitor *v,
     }
 
     s390_ipl_fmt_loadparm(ms->loadparm, val, errp);
+    g_free(val);
 }
 
 static void ccw_machine_class_init(ObjectClass *oc, const void *data)
Signature · 1 line
2.35.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 28 lines · Fabiano Rosas

ASAN spotted a leaking string in machine_set_loadparm():

Direct leak of 9 byte(s) in 1 object(s) allocated from:

     #0 0x560ffb5bb379 in malloc ../projects/compiler-rt/lib/asan/asan_malloc_linux.cpp:69:3
     #1 0x7f1aca926518 in g_malloc ../glib/gmem.c:106
     #2 0x7f1aca94113e in g_strdup ../glib/gstrfuncs.c:364
     #3 0x560ffc8afbf9 in qobject_input_type_str ../qapi/qobject-input-visitor.c:542:12
     #4 0x560ffc8a80ff in visit_type_str ../qapi/qapi-visit-core.c:349:10
     #5 0x560ffbe6053a in machine_set_loadparm ../hw/s390x/s390-virtio-ccw.c:802:10
     #6 0x560ffc0c5e52 in object_property_set ../qom/object.c:1450:5
     #7 0x560ffc0d4175 in object_property_set_qobject ../qom/qom-qobject.c:28:10
     #8 0x560ffc0c6004 in object_property_set_str ../qom/object.c:1458:15
     #9 0x560ffbe2ae60 in update_machine_ipl_properties ../hw/s390x/ipl.c:569:9
     #10 0x560ffbe2aa65 in s390_ipl_update_diag308 ../hw/s390x/ipl.c:594:5
     #11 0x560ffbdee132 in handle_diag_308 ../target/s390x/diag.c:147:9
     #12 0x560ffbebb956 in helper_diag ../target/s390x/tcg/misc_helper.c:137:9
     #13 0x7f1a3c51c730  (/memfd:tcg-jit (deleted)+0x39730)
---
  hw/s390x/s390-virtio-ccw.c | 1 +
  1 file changed, 1 insertion(+)
hw/s390x/s390-virtio-ccw.c +0 -0
index d5658afed9..744e901db8 100644

hw/s390x/s390-virtio-ccw.c static void machine_set_loadparm(Object *obj, Visitor *v, · line 810

Quoted 7 lines
hw/s390x/s390-virtio-ccw.c +1 -0
@@ -804,6 +804,7 @@ static void machine_set_loadparm(Object *obj, Visitor *v,
      }
 
      s390_ipl_fmt_loadparm(ms->loadparm, val, errp);
+    g_free(val);
  }
 
  static void ccw_machine_class_init(ObjectClass *oc, const void *data)

and queued it!

Reviewed-by on v1 1/1
#2 lore raw
In reply to Fabiano Rosas
Quoted 18 lines · Fabiano Rosas

ASAN spotted a leaking string in machine_set_loadparm():

Direct leak of 9 byte(s) in 1 object(s) allocated from:

     #0 0x560ffb5bb379 in malloc ../projects/compiler-rt/lib/asan/asan_malloc_linux.cpp:69:3
     #1 0x7f1aca926518 in g_malloc ../glib/gmem.c:106
     #2 0x7f1aca94113e in g_strdup ../glib/gstrfuncs.c:364
     #3 0x560ffc8afbf9 in qobject_input_type_str ../qapi/qobject-input-visitor.c:542:12
     #4 0x560ffc8a80ff in visit_type_str ../qapi/qapi-visit-core.c:349:10
     #5 0x560ffbe6053a in machine_set_loadparm ../hw/s390x/s390-virtio-ccw.c:802:10
     #6 0x560ffc0c5e52 in object_property_set ../qom/object.c:1450:5
     #7 0x560ffc0d4175 in object_property_set_qobject ../qom/qom-qobject.c:28:10
     #8 0x560ffc0c6004 in object_property_set_str ../qom/object.c:1458:15
     #9 0x560ffbe2ae60 in update_machine_ipl_properties ../hw/s390x/ipl.c:569:9
     #10 0x560ffbe2aa65 in s390_ipl_update_diag308 ../hw/s390x/ipl.c:594:5
     #11 0x560ffbdee132 in handle_diag_308 ../target/s390x/diag.c:147:9
     #12 0x560ffbebb956 in helper_diag ../target/s390x/tcg/misc_helper.c:137:9
     #13 0x7f1a3c51c730  (/memfd:tcg-jit (deleted)+0x39730)
Quoted 4 lines
---
  hw/s390x/s390-virtio-ccw.c | 1 +
  1 file changed, 1 insertion(+)
#3 lore raw
Quoted 2 lines · Philippe Mathieu-Daudé
Quoted 1 line · Fabiano Rosas

ASAN spotted a leaking string in machine_set_loadparm():

What about ccw_device_set_loadparm() in hw/s390x/ccw-device.c?

Quoted 24 lines
Quoted 17 lines

Direct leak of 9 byte(s) in 1 object(s) allocated from:
     #0 0x560ffb5bb379 in malloc ../projects/compiler-rt/lib/asan/ asan_malloc_linux.cpp:69:3 #1 0x7f1aca926518 in g_malloc ../glib/gmem.c:106
     #2 0x7f1aca94113e in g_strdup ../glib/gstrfuncs.c:364
     #3 0x560ffc8afbf9 in qobject_input_type_str ../qapi/qobject- input-visitor.c:542:12 #4 0x560ffc8a80ff in visit_type_str ../qapi/qapi-visit-core.c:349:10
     #5 0x560ffbe6053a in machine_set_loadparm ../hw/s390x/s390- virtio-ccw.c:802:10 #6 0x560ffc0c5e52 in object_property_set ../qom/object.c:1450:5
     #7 0x560ffc0d4175 in object_property_set_qobject ../qom/qom- qobject.c:28:10 #8 0x560ffc0c6004 in object_property_set_str ../qom/object.c:1458:15
     #9 0x560ffbe2ae60 in update_machine_ipl_properties ../hw/s390x/ ipl.c:569:9 #10 0x560ffbe2aa65 in s390_ipl_update_diag308 ../hw/s390x/ ipl.c:594:5 #11 0x560ffbdee132 in handle_diag_308 ../target/s390x/diag.c:147:9
     #12 0x560ffbebb956 in helper_diag ../target/s390x/tcg/ misc_helper.c:137:9 #13 0x7f1a3c51c730  (/memfd:tcg-jit (deleted)+0x39730)

Quoted 4 lines

---
  hw/s390x/s390-virtio-ccw.c | 1 +

  1 file changed, 1 insertion(+)
#4 lore raw
Quoted 6 lines · Philippe Mathieu-Daudé
Quoted 2 lines · Philippe Mathieu-Daudé
Quoted 1 line · Fabiano Rosas

ASAN spotted a leaking string in machine_set_loadparm():

What about ccw_device_set_loadparm() in hw/s390x/ccw-device.c?

Yep, that one as well. I'll send a patch. Thanks

#5 lore raw
Quoted 10 lines · Fabiano Rosas
Quoted 6 lines · Philippe Mathieu-Daudé
Quoted 2 lines · Philippe Mathieu-Daudé
Quoted 1 line · Fabiano Rosas

ASAN spotted a leaking string in machine_set_loadparm():

What about ccw_device_set_loadparm() in hw/s390x/ccw-device.c?

Yep, that one as well. I'll send a patch. Thanks

Did you ever send it?

Thomas

#6 lore raw
Quoted 5 lines · Thomas Huth
Quoted 4 lines · Fabiano Rosas
Quoted 2 lines · Philippe Mathieu-Daudé
Quoted 1 line · Philippe Mathieu-Daudé

On 9/5/25 19:49, Fabiano Rosas wrote:

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line

ASAN spotted a leaking string in machine_set_loadparm():

What about ccw_device_set_loadparm() in hw/s390x/ccw-device.c?

Yep, that one as well. I'll send a patch. Thanks

Did you ever send it?

Sorry, no. Got sidetracked as usual. I'll mark this email so I don't forget.

Quoted 1 line

Thomas

#7 lore raw

Am 24.06.2025 um 14:34 hat Fabiano Rosas geschrieben:

Quoted 9 lines
Quoted 7 lines · Thomas Huth
Quoted 6 lines · Fabiano Rosas
Quoted 4 lines · Philippe Mathieu-Daudé
Quoted 2 lines · Philippe Mathieu-Daudé
Quoted 1 line · Fabiano Rosas

ASAN spotted a leaking string in machine_set_loadparm():

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

What about ccw_device_set_loadparm() in hw/s390x/ccw-device.c?

Yep, that one as well. I'll send a patch. Thanks

Did you ever send it?

Sorry, no. Got sidetracked as usual. I'll mark this email so I don't forget.

I think Thomas asked because I posted the fix in our downstream bug tracker. I just sent it as a proper patch.

Kevin

Reviewed-by on v1 1/1
#8 lore raw
In reply to Fabiano Rosas
Quoted 18 lines · On Fri, 9 May 2025 14:49:38 -0300 Fabiano Rosas <[email protected]> wrote:

ASAN spotted a leaking string in machine_set_loadparm():

Direct leak of 9 byte(s) in 1 object(s) allocated from:

    #0 0x560ffb5bb379 in malloc ../projects/compiler-rt/lib/asan/asan_malloc_linux.cpp:69:3
    #1 0x7f1aca926518 in g_malloc ../glib/gmem.c:106
    #2 0x7f1aca94113e in g_strdup ../glib/gstrfuncs.c:364
    #3 0x560ffc8afbf9 in qobject_input_type_str ../qapi/qobject-input-visitor.c:542:12
    #4 0x560ffc8a80ff in visit_type_str ../qapi/qapi-visit-core.c:349:10
    #5 0x560ffbe6053a in machine_set_loadparm ../hw/s390x/s390-virtio-ccw.c:802:10
    #6 0x560ffc0c5e52 in object_property_set ../qom/object.c:1450:5
    #7 0x560ffc0d4175 in object_property_set_qobject ../qom/qom-qobject.c:28:10
    #8 0x560ffc0c6004 in object_property_set_str ../qom/object.c:1458:15
    #9 0x560ffbe2ae60 in update_machine_ipl_properties ../hw/s390x/ipl.c:569:9
    #10 0x560ffbe2aa65 in s390_ipl_update_diag308 ../hw/s390x/ipl.c:594:5
    #11 0x560ffbdee132 in handle_diag_308 ../target/s390x/diag.c:147:9
    #12 0x560ffbebb956 in helper_diag ../target/s390x/tcg/misc_helper.c:137:9
    #13 0x7f1a3c51c730  (/memfd:tcg-jit (deleted)+0x39730)
Quoted 1 line