)]}' { "commit": "fc13d937269c1cd01a4b7720c1dcce01722727a2", "tree": "394f5db89292f081978466db6efbb8748b1216e1", "parents": [ "347888113020e874027cb200bb38aa0852e42839" ], "author": { "name": "Michael Roth", "email": "mdroth@linux.vnet.ibm.com", "time": "Tue May 20 12:20:39 2014 -0500" }, "committer": { "name": "Luiz Capitulino", "email": "lcapitulino@redhat.com", "time": "Wed May 21 09:25:31 2014 -0400" }, "message": "qapi: zero-initialize all QMP command parameters\n\nIn general QMP command parameter values are specified by consumers of the\nQMP/HMP interface, but in the case of optional parameters these values may\nbe left uninitialized.\n\nIt is considered a bug for code to make use of optional parameters that have\nnot been flagged as being present by the marshalling code (via corresponding\nhas_\u003cparameter\u003e parameter), however our marshalling code will still pass\nthese uninitialized values on to the corresponding QMP function (to then\nbe ignored). Some compilers (clang in particular) consider this unsafe\nhowever, and generate warnings as a result. As reported by Peter Maydell:\n\n This is something clang\u0027s -fsanitize\u003dundefined spotted. The\n code generated by qapi-commands.py in qmp-marshal.c for\n qmp_marshal_* functions where there are some optional\n arguments looks like this:\n\n bool has_force \u003d false;\n bool force;\n\n mi \u003d qmp_input_visitor_new_strict(QOBJECT(args));\n v \u003d qmp_input_get_visitor(mi);\n visit_type_str(v, \u0026device, \"device\", errp);\n visit_start_optional(v, \u0026has_force, \"force\", errp);\n if (has_force) {\n visit_type_bool(v, \u0026force, \"force\", errp);\n }\n visit_end_optional(v, errp);\n qmp_input_visitor_cleanup(mi);\n\n if (error_is_set(errp)) {\n goto out;\n }\n qmp_eject(device, has_force, force, errp);\n\n In the case where has_force is false, we never initialize\n force, but then we use it by passing it to qmp_eject.\n I imagine we don\u0027t then actually use the value, but clang\n complains in particular for \u0027bool\u0027 variables because the value\n that ends up being loaded from memory for \u0027force\u0027 is not either\n 0 or 1 (being uninitialized stack contents).\n\nFix this by initializing all QMP command parameters to {0} in the\nmarshalling code prior to passing them on to the QMP functions.\n\nSigned-off-by: Michael Roth \u003cmdroth@linux.vnet.ibm.com\u003e\nReported-by: Peter Maydell \u003cpeter.maydell@linaro.org\u003e\nTested-by: Peter Maydell \u003cpeter.maydell@linaro.org\u003e\nReviewed-by: Eric Blake \u003ceblake@redhat.com\u003e\nReviewed-by: Markus Armbruster \u003carmbru@redhat.com\u003e\nSigned-off-by: Luiz Capitulino \u003clcapitulino@redhat.com\u003e\n", "tree_diff": [ { "type": "modify", "old_id": "386f17ef44b35773cbe2d42196d96e84715421ba", "old_mode": 33188, "old_path": "scripts/qapi-commands.py", "new_id": "7d93d01ed2f7906ebc1217dce9d0918ede6543c9", "new_mode": 33188, "new_path": "scripts/qapi-commands.py" } ] }