From: Cyrill Gorcunov <gorcunov@openvz.org>
To: Pekka Enberg <penberg@kernel.org>,
Sasha Levin <levinsasha928@gmail.com>,
Asias He <asias.hejun@gmail.com>, Ingo Molnar <mingo@elte.hu>,
KVM-ML <kvm@vger.kernel.org>
Subject: [PATCH] kvm tool: Make kvm structure to carry name copy
Date: Fri, 3 Feb 2012 23:57:15 +0400 [thread overview]
Message-ID: <20120203195715.GF3314@moon> (raw)
If guest name is used (which is default case) the kvm might end
up carrying the pointer to name which is allocated on stack.
kvm_cmd_run_init
(on stack) default_name
kvm__init(..., default_name)
kvm->name = default_name
So I think better to allow kvm to carry own copy
of guest name. 64 symbols should be more than enough.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
I hope I didn't miss anything?
tools/kvm/kvm.c | 2 +-
tools/kvm/powerpc/include/kvm/kvm-arch.h | 2 +-
tools/kvm/x86/include/kvm/kvm-arch.h | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
Index: linux-2.6.git/tools/kvm/kvm.c
===================================================================
--- linux-2.6.git.orig/tools/kvm/kvm.c
+++ linux-2.6.git/tools/kvm/kvm.c
@@ -384,7 +384,7 @@ struct kvm *kvm__init(const char *kvm_de
kvm__arch_init(kvm, hugetlbfs_path, ram_size);
- kvm->name = name;
+ strncpy(kvm->name, name, sizeof(kvm->name));
kvm_ipc__start(kvm__create_socket(kvm));
kvm_ipc__register_handler(KVM_IPC_PID, kvm__pid);
Index: linux-2.6.git/tools/kvm/powerpc/include/kvm/kvm-arch.h
===================================================================
--- linux-2.6.git.orig/tools/kvm/powerpc/include/kvm/kvm-arch.h
+++ linux-2.6.git/tools/kvm/powerpc/include/kvm/kvm-arch.h
@@ -64,7 +64,7 @@ struct kvm {
unsigned long fdt_gra;
unsigned long initrd_gra;
unsigned long initrd_size;
- const char *name;
+ char name[64];
int vm_state;
};
Index: linux-2.6.git/tools/kvm/x86/include/kvm/kvm-arch.h
===================================================================
--- linux-2.6.git.orig/tools/kvm/x86/include/kvm/kvm-arch.h
+++ linux-2.6.git/tools/kvm/x86/include/kvm/kvm-arch.h
@@ -48,7 +48,7 @@ struct kvm {
struct disk_image **disks;
int nr_disks;
- const char *name;
+ char name[64];
int vm_state;
};
next reply other threads:[~2012-02-03 19:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-03 19:57 Cyrill Gorcunov [this message]
2012-02-04 12:15 ` [PATCH] kvm tool: Make kvm structure to carry name copy Pekka Enberg
2012-02-04 12:20 ` Cyrill Gorcunov
2012-02-04 12:26 ` Cyrill Gorcunov
2012-02-04 12:57 ` Pekka Enberg
2012-02-04 13:08 ` Cyrill Gorcunov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120203195715.GF3314@moon \
--to=gorcunov@openvz.org \
--cc=asias.hejun@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=levinsasha928@gmail.com \
--cc=mingo@elte.hu \
--cc=penberg@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.