[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-7.2.5 05/36] qemu-nbd: regression with arguments passing into nb
From: |
Michael Tokarev |
Subject: |
[Stable-7.2.5 05/36] qemu-nbd: regression with arguments passing into nbd_client_thread() |
Date: |
Fri, 4 Aug 2023 21:53:27 +0300 |
From: "Denis V. Lunev" <den@openvz.org>
Unfortunately
commit 03b67621445d601c9cdc7dfe25812e9f19b81488
(7.2: 6e216d21b56a7545a05080a370b5ca7491fecfb3)
Author: Denis V. Lunev <den@openvz.org>
Date: Mon Jul 17 16:55:40 2023 +0200
qemu-nbd: pass structure into nbd_client_thread instead of plain char*
has introduced a regression. struct NbdClientOpts resides on stack inside
'if' block. This specifically means that this stack space could be reused
once the execution will leave that block of the code.
This means that parameters passed into nbd_client_thread could be
overwritten at any moment.
The patch moves the data to the namespace of main() function effectively
preserving it for the whole process lifetime.
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Eric Blake <eblake@redhat.com>
CC: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
CC: <qemu-stable@nongnu.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-ID: <20230727105828.324314-1-den@openvz.org>
Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit e5b815b0defcc3617f473ba70c3e675ef0ee69c2)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Mjt: add reference to 6e216d21b56a7545a05080a370b5ca7491fecfb3 for 7.2 branch)
diff --git a/qemu-nbd.c b/qemu-nbd.c
index bcdb74ff13..f71f5125d8 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -584,6 +584,9 @@ int main(int argc, char **argv)
const char *pid_file_name = NULL;
const char *selinux_label = NULL;
BlockExportOptions *export_opts;
+#if HAVE_NBD_DEVICE
+ struct NbdClientOpts opts;
+#endif
#ifdef CONFIG_POSIX
os_setup_early_signal_handling();
@@ -1122,7 +1125,7 @@ int main(int argc, char **argv)
if (device) {
#if HAVE_NBD_DEVICE
int ret;
- struct NbdClientOpts opts = {
+ opts = (struct NbdClientOpts) {
.device = device,
.fork_process = fork_process,
};
--
2.39.2
- [PATCH v2 0/7] target/mips: Convert Loongson LEXT opcodes to decodetree, Philippe Mathieu-Daudé, 2023/08/31
- [PATCH v2 1/7] target/mips: Simplify Loongson MULTU.G opcode, Philippe Mathieu-Daudé, 2023/08/31
- [PATCH v2 2/7] target/mips: Re-introduce OPC_ADDUH_QB_DSP and OPC_MUL_PH_DSP, Philippe Mathieu-Daudé, 2023/08/31
- [PATCH v2 3/7] target/mips: Convert Loongson DDIV.G opcodes to decodetree, Philippe Mathieu-Daudé, 2023/08/31
- [PATCH v2 4/7] target/mips: Convert Loongson DIV.G opcodes to decodetree, Philippe Mathieu-Daudé, 2023/08/31
- [PATCH v2 5/7] target/mips: Convert Loongson [D]DIVU.G opcodes to decodetree, Philippe Mathieu-Daudé, 2023/08/31
- [PATCH v2 6/7] target/mips: Convert Loongson [D]MOD[U].G opcodes to decodetree, Philippe Mathieu-Daudé, 2023/08/31
- [PATCH v2 7/7] target/mips: Convert Loongson [D]MULT[U].G opcodes to decodetree, Philippe Mathieu-Daudé, 2023/08/31