[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v10 03/30] qobject: Protect against use-after-free i
From: |
Eric Blake |
Subject: |
[Qemu-devel] [PATCH v10 03/30] qobject: Protect against use-after-free in qobject_decref() |
Date: |
Thu, 5 Nov 2015 23:35:27 -0700 |
Adding an assertion to qobject_decref() will ensure that a
programming error causing use-after-free will result in
immediate failure (provided no other thread has started
using the memory) instead of silently attempting to wrap
refcnt around and leaving the problem to potentially bite
later at a harder point to diagnose.
Suggested-by: Markus Armbruster <address@hidden>
Signed-off-by: Eric Blake <address@hidden>
---
v10: new patch
---
include/qapi/qmp/qobject.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/qapi/qmp/qobject.h b/include/qapi/qmp/qobject.h
index c856f55..4b96ed5 100644
--- a/include/qapi/qmp/qobject.h
+++ b/include/qapi/qmp/qobject.h
@@ -90,6 +90,7 @@ static inline void qobject_incref(QObject *obj)
*/
static inline void qobject_decref(QObject *obj)
{
+ assert(!obj || obj->refcnt);
if (obj && --obj->refcnt == 0) {
assert(obj->type != NULL);
assert(obj->type->destroy != NULL);
--
2.4.3
- [Qemu-devel] [PATCH v10 00/30] qapi member collision (post-introspection cleanups, subset C'), Eric Blake, 2015/11/06
- [Qemu-devel] [PATCH v10 10/30] qapi: More tests of input arrays, Eric Blake, 2015/11/06
- [Qemu-devel] [PATCH v10 09/30] qapi: Test failure in middle of array parse, Eric Blake, 2015/11/06
- [Qemu-devel] [PATCH v10 03/30] qobject: Protect against use-after-free in qobject_decref(),
Eric Blake <=
- [Qemu-devel] [PATCH v10 08/30] qapi: More tests of alternate output, Eric Blake, 2015/11/06
- [Qemu-devel] [PATCH v10 02/30] qapi: Strengthen test of TestStructList, Eric Blake, 2015/11/06
- [Qemu-devel] [PATCH v10 04/30] qapi: Share test_init code in test-qmp-input*, Eric Blake, 2015/11/06
- [Qemu-devel] [PATCH v10 01/30] qapi: Use generated TestStruct machinery in tests, Eric Blake, 2015/11/06
- [Qemu-devel] [PATCH v10 14/30] qapi-types: Consolidate gen_struct() and gen_union(), Eric Blake, 2015/11/06
- [Qemu-devel] [PATCH v10 12/30] qapi-introspect: Document lack of sorting, Eric Blake, 2015/11/06