[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 05/13] memfd: fix possible usage of the uninitialized
From: |
Thomas Huth |
Subject: |
[Qemu-devel] [PULL 05/13] memfd: fix possible usage of the uninitialized file descriptor |
Date: |
Tue, 25 Sep 2018 18:03:39 +0200 |
From: Dima Stepanov <address@hidden>
The qemu_memfd_alloc_check() routine allocates the fd variable on stack.
This variable is initialized inside the qemu_memfd_alloc() function.
There are several cases when *fd will be left unintialized which can
lead to the unexpected close() in the qemu_memfd_free() call.
Set file descriptor to -1 before calling the qemu_memfd_alloc routine.
Signed-off-by: Dima Stepanov <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
Reviewed-by: Thomas Huth <address@hidden>
Signed-off-by: Thomas Huth <address@hidden>
---
util/memfd.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/util/memfd.c b/util/memfd.c
index d248a53..6287946 100644
--- a/util/memfd.c
+++ b/util/memfd.c
@@ -187,6 +187,7 @@ bool qemu_memfd_alloc_check(void)
int fd;
void *ptr;
+ fd = -1;
ptr = qemu_memfd_alloc("test", 4096, 0, &fd, NULL);
memfd_check = ptr ? MEMFD_OK : MEMFD_KO;
qemu_memfd_free(ptr, 4096, fd);
--
1.8.3.1
- [Qemu-devel] [PULL 00/13] Deprecation, qtests and some trivial doc updates, Thomas Huth, 2018/09/25
- [Qemu-devel] [PULL 01/13] Makefile: Add missing dependency for qemu-deprecated.texi, Thomas Huth, 2018/09/25
- [Qemu-devel] [PULL 04/13] hw/core/machine: Officially deprecate the enforce-config-section parameter, Thomas Huth, 2018/09/25
- [Qemu-devel] [PULL 03/13] net/slirp: Deprecate the [hub_id name] parameter tuple, Thomas Huth, 2018/09/25
- [Qemu-devel] [PULL 05/13] memfd: fix possible usage of the uninitialized file descriptor,
Thomas Huth <=
- [Qemu-devel] [PULL 06/13] trivial: Make bios files and source files non-executable, Thomas Huth, 2018/09/25
- [Qemu-devel] [PULL 02/13] net: Deprecate the "name" parameter of -net, Thomas Huth, 2018/09/25
- [Qemu-devel] [PULL 07/13] docs: Fix some typos (most found by codespell), Thomas Huth, 2018/09/25
- [Qemu-devel] [PULL 08/13] qdev: fix a typo in comment, Thomas Huth, 2018/09/25
- [Qemu-devel] [PULL 09/13] hw/qdev-core: Fix description of instance_init, Thomas Huth, 2018/09/25
- [Qemu-devel] [PULL 12/13] Revert "check: Move endianess test to common", Thomas Huth, 2018/09/25
- [Qemu-devel] [PULL 11/13] Revert "check: Move wdt_ib700 test to common", Thomas Huth, 2018/09/25
- [Qemu-devel] [PULL 10/13] tests/migration: Speed up the test on ppc64, Thomas Huth, 2018/09/25
- [Qemu-devel] [PULL 13/13] Revert "check: Move VMXNET3 test to common", Thomas Huth, 2018/09/25
- Re: [Qemu-devel] [PULL 00/13] Deprecation, qtests and some trivial doc updates, Peter Maydell, 2018/09/27