[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 03/12] coroutine: add check for SafeStack in sigaltstack
From: |
Stefan Hajnoczi |
Subject: |
[PULL 03/12] coroutine: add check for SafeStack in sigaltstack |
Date: |
Wed, 24 Jun 2020 11:02:01 +0100 |
From: Daniele Buono <dbuono@linux.vnet.ibm.com>
Current implementation of LLVM's SafeStack is not compatible with
code that uses an alternate stack created with sigaltstack().
Since coroutine-sigaltstack relies on sigaltstack(), it is not
compatible with SafeStack. The resulting binary is incorrect, with
different coroutines sharing the same unsafe stack and producing
undefined behavior at runtime.
In the future LLVM may provide a SafeStack implementation compatible with
sigaltstack(). In the meantime, if SafeStack is desired, the coroutine
implementation from coroutine-ucontext should be used.
As a safety check, add a control in coroutine-sigaltstack to throw a
preprocessor #error if SafeStack is enabled and we are trying to
use coroutine-sigaltstack to implement coroutines.
Signed-off-by: Daniele Buono <dbuono@linux.vnet.ibm.com>
Message-id: 20200529205122.714-3-dbuono@linux.vnet.ibm.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
util/coroutine-sigaltstack.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/util/coroutine-sigaltstack.c b/util/coroutine-sigaltstack.c
index f6fc49a0e5..aade82afb8 100644
--- a/util/coroutine-sigaltstack.c
+++ b/util/coroutine-sigaltstack.c
@@ -30,6 +30,10 @@
#include "qemu-common.h"
#include "qemu/coroutine_int.h"
+#ifdef CONFIG_SAFESTACK
+#error "SafeStack is not compatible with code run in alternate signal stacks"
+#endif
+
typedef struct {
Coroutine base;
void *stack;
--
2.26.2
- [PULL 00/12] Block patches, Stefan Hajnoczi, 2020/06/24
- [PULL 01/12] minikconf: explicitly set encoding to UTF-8, Stefan Hajnoczi, 2020/06/24
- [PULL 02/12] coroutine: support SafeStack in ucontext backend, Stefan Hajnoczi, 2020/06/24
- [PULL 03/12] coroutine: add check for SafeStack in sigaltstack,
Stefan Hajnoczi <=
- [PULL 04/12] configure: add flags to support SafeStack, Stefan Hajnoczi, 2020/06/24
- [PULL 05/12] check-block: enable iotests with SafeStack, Stefan Hajnoczi, 2020/06/24
- [PULL 06/12] block/nvme: poll queues without q->lock, Stefan Hajnoczi, 2020/06/24
- [PULL 07/12] block/nvme: drop tautologous assertion, Stefan Hajnoczi, 2020/06/24
- [PULL 08/12] block/nvme: don't access CQE after moving cq.head, Stefan Hajnoczi, 2020/06/24
- [PULL 09/12] block/nvme: switch to a NVMeRequest freelist, Stefan Hajnoczi, 2020/06/24
- [PULL 10/12] block/nvme: clarify that free_req_queue is protected by q->lock, Stefan Hajnoczi, 2020/06/24
- [PULL 11/12] block/nvme: keep BDRVNVMeState pointer in NVMeQueuePair, Stefan Hajnoczi, 2020/06/24
- [PULL 12/12] block/nvme: support nested aio_poll(), Stefan Hajnoczi, 2020/06/24
- Re: [PULL 00/12] Block patches, Peter Maydell, 2020/06/25