fix segfault in (iscsi) option parsing
cover fix segfault in (iscsi) option parsing
current git master segfaults if an iscsi option is specified in command line.
Peter Lieven (2):
qemu-option: avoid segfault if QemuOptsList == NULL vl.c: fix segfault in iscsi options parsing
block/iscsi.c | 27 --------------------------- util/qemu-option.c | 1 + vl.c | 40 +++++++++++++++++++++++++++++++++++++--- 3 files changed, 38 insertions(+), 30 deletions(-)
Signature · 1 line
1.7.9.5
PATCH 1/2 qemu-option: avoid segfault if QemuOptsList == NULL
--- util/qemu-option.c | 1 + 1 file changed, 1 insertion(+)
util/qemu-option.c +1 -0
@@ -938,6 +938,7 @@ static QemuOpts *opts_parse(QemuOptsList *list, const char *params,QemuOpts *opts;Error *local_err =NULL ; +assert (list !=NULL );assert (!permit_abbrev || list->implied_opt_name); firstname = permit_abbrev ? list->implied_opt_name :NULL ;
Signature · 1 line
1.7.9.5
PATCH 2/2 vl.c: fix segfault in iscsi options parsing
In reply to Peter Lieventhis patch fixes parsing of iscsi options such as initiator-name passed to command line via -iscsi option group.
because iscsi options where registered too late qemu_find_opts returned NULL leading to a segfault in qemu_opts_parse.
--- block/iscsi.c | 27 --------------------------- vl.c | 40 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 30 deletions(-)
block/iscsi.c +0 -27
@@ -1263,36 +1263,9 @@ static BlockDriver bdrv_iscsi = {#endif }; -static QemuOptsList qemu_iscsi_opts = { - .name ="iscsi" , - .head =QTAILQ_HEAD_INITIALIZER (qemu_iscsi_opts.head), - .desc = { - { - .name ="user" , - .type =QEMU_OPT_STRING , - .help ="username for CHAP authentication to target" , - },{ - .name ="password" , - .type =QEMU_OPT_STRING , - .help ="password for CHAP authentication to target" , - },{ - .name ="header-digest" , - .type =QEMU_OPT_STRING , - .help ="HeaderDigest setting. " -"{CRC32C|CRC32C-NONE|NONE-CRC32C|NONE}" , - },{ - .name ="initiator-name" , - .type =QEMU_OPT_STRING , - .help ="Initiator iqn name to use when connecting" , - }, - {/* end of list */ } - }, -}; -static void iscsi_block_init (void ) {bdrv_register (&bdrv_iscsi); -qemu_add_opts (&qemu_iscsi_opts); }block_init (iscsi_block_init);
vl.c +37 -3
@@ -517,6 +517,34 @@ static QemuOptsList qemu_tpmdev_opts = { }, }; +#ifdef CONFIG_LIBISCSI +static QemuOptsList qemu_iscsi_opts = { + .name ="iscsi" , + .head =QTAILQ_HEAD_INITIALIZER (qemu_iscsi_opts.head), + .desc = { + { + .name ="user" , + .type =QEMU_OPT_STRING , + .help ="username for CHAP authentication to target" , + },{ + .name ="password" , + .type =QEMU_OPT_STRING , + .help ="password for CHAP authentication to target" , + },{ + .name ="header-digest" , + .type =QEMU_OPT_STRING , + .help ="HeaderDigest setting. " +"{CRC32C|CRC32C-NONE|NONE-CRC32C|NONE}" , + },{ + .name ="initiator-name" , + .type =QEMU_OPT_STRING , + .help ="Initiator iqn name to use when connecting" , + }, + {/* end of list */ } + }, +}; +#endif +const char *qemu_get_vm_name (void ) {return qemu_name;
@@ -2899,6 +2927,9 @@ int main(int argc, char **argv, char **envp)qemu_add_opts (&qemu_add_fd_opts);qemu_add_opts (&qemu_object_opts);qemu_add_opts (&qemu_tpmdev_opts); +#ifdef CONFIG_LIBISCSI +qemu_add_opts (&qemu_iscsi_opts); +#endif runstate_init ();
@@ -3199,14 +3230,17 @@ int main(int argc, char **argv, char **envp)exit (1 ); }break ; -#ifdef CONFIG_LIBISCSI case QEMU_OPTION_iscsi: - opts =qemu_opts_parse (qemu_find_opts ("iscsi" ), optarg,0 ); + olist =qemu_find_opts ("iscsi" ); +if (!olist) { +fprintf (stderr,"iscsi is not supported by this qemu build.\n" ); +exit (1 ); + } + opts =qemu_opts_parse (olist, optarg,0 );if (!opts) {exit (1 ); }break ; -#endif #ifdef CONFIG_SLIRP case QEMU_OPTION_tftp: legacy_tftp_prefix = optarg;
Signature · 1 line
1.7.9.5
Paolo, please have a look.
Quoted 11 lines · Peter Lieven
current git master segfaults if an iscsi option is specified in command line.
Peter Lieven (2):
qemu-option: avoid segfault if QemuOptsList == NULLvl.c: fix segfault in iscsi options parsingblock/iscsi.c | 27 --------------------------- util/qemu-option.c | 1 + vl.c | 40 +++++++++++++++++++++++++++++++++++++--- 3 files changed, 38 insertions(+), 30 deletions(-)
Il 19/03/2013 09:51, Markus Armbruster ha scritto:
Quoted 1 line
Paolo, please have a look.
Why isn't it enough to call bdrv_init_with_whitelist earlier?
There is no conditional logic in it, the whitelist is checked at open time.
Paolo
Quoted 15 lines
Quoted 11 lines · Peter Lieven
current git master segfaults if an iscsi option is specified in command line.
Peter Lieven (2):
qemu-option: avoid segfault if QemuOptsList == NULLvl.c: fix segfault in iscsi options parsingblock/iscsi.c | 27 --------------------------- util/qemu-option.c | 1 + vl.c | 40 +++++++++++++++++++++++++++++++++++++--- 3 files changed, 38 insertions(+), 30 deletions(-)
Quoted 5 lines · Paolo Bonzini
Il 19/03/2013 09:51, Markus Armbruster ha scritto:
Quoted 1 line
Paolo, please have a look.
Why isn't it enough to call
bdrv_init_with_whitelistearlier?There is no conditional logic in it, the whitelist is checked at open time.
Has anyone tested if -spice is working? In this case bdrv_init_with_whitelist() won't help here.
Anyway, I would like to change the -iscsi code in vl.c to throw an error, if iscsi support is not compiled in (like it is done with spice).
Peter
Quoted 17 lines
Paolo
Quoted 14 lines
Quoted 11 lines · Peter Lieven
current git master segfaults if an iscsi option is specified in command line.
Peter Lieven (2):
qemu-option: avoid segfault if QemuOptsList == NULLvl.c: fix segfault in iscsi options parsingblock/iscsi.c | 27 --------------------------- util/qemu-option.c | 1 + vl.c | 40 +++++++++++++++++++++++++++++++++++++--- 3 files changed, 38 insertions(+), 30 deletions(-)
Signature · 16 lines
Mit freundlichen Grüßen Peter Lieven ........................................................... KAMP Netzwerkdienste GmbH Vestische Str. 89-91 | 46117 Oberhausen Tel: +49 (0) 208.89 402-50 | Fax: +49 (0) 208.89 402-40 [email protected] | http://www.kamp.de Geschäftsführer: Heiner Lante | Michael Lante Amtsgericht Duisburg | HRB Nr. 12154 USt-Id-Nr.: DE 120607556 ...........................................................
Il 19/03/2013 16:54, Peter Lieven ha scritto:
Quoted 9 lines · Paolo Bonzini
Quoted 6 lines
Il 19/03/2013 09:51, Markus Armbruster ha scritto:
Quoted 1 line
Paolo, please have a look.
Why isn't it enough to call
bdrv_init_with_whitelistearlier?There is no conditional logic in it, the whitelist is checked at open time.
Has anyone tested if -spice is working?
It is.
machine_init entries are processed just below the other qemu_add_opts.
Paolo
In this case
Quoted 27 lines
bdrv_init_with_whitelist()won't help here.Anyway, I would like to change the -iscsi code in
vl.cto throw an error, if iscsi support is not
compiled in (like it is done with spice).Peter
Quoted 17 lines
Paolo
Quoted 14 lines
Quoted 11 lines · Peter Lieven
current git master segfaults if an iscsi option is specified in command line.
Peter Lieven (2):
qemu-option: avoid segfault if QemuOptsList == NULLvl.c: fix segfault in iscsi options parsingblock/iscsi.c | 27 --------------------------- util/qemu-option.c | 1 + vl.c | 40 +++++++++++++++++++++++++++++++++++++--- 3 files changed, 38 insertions(+), 30 deletions(-)
Am 19.03.2013 um 18:07 schrieb Paolo Bonzini <[email protected]>:
Quoted 6 lines
Il 19/03/2013 16:54, Peter Lieven ha scritto:
Quoted 5 lines · Paolo Bonzini
Quoted 4 lines
Il 19/03/2013 09:51, Markus Armbruster ha scritto:
Quoted 1 line
Paolo, please have a look.
Why isn't it enough to call
bdrv_init_with_whitelistearlier?
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
There is no conditional logic in it, the whitelist is checked at open time.
Has anyone tested if -spice is working?
It is.
machine_initentries are processed just below the otherqemu_add_opts.
Ok, if you agree I would prepare a new version of this patch set with 3 patches:
1) move up brd_init_with_whitelist
2) throw an error if -iscsi is used without compile libiscsi support
3) assert that QemuOptsList != NULL to avoid further segfaults.
I currently see a segfault on VM start in libiscsi with latest git. Whereas my old qemu-kvm 1.2.0 is working with the same command line and libiscsi library. As soon as I have sorted this out I will send a new patch set.
Peter
Quoted 32 lines
Paolo
In this case
Quoted 27 lines
bdrv_init_with_whitelist()won't help here.Anyway, I would like to change the -iscsi code in
vl.cto throw an error, if iscsi support is not
compiled in (like it is done with spice).Peter
Quoted 17 lines
Paolo
Quoted 14 lines
Quoted 11 lines · Peter Lieven
current git master segfaults if an iscsi option is specified in command line.
Peter Lieven (2):
qemu-option: avoid segfault if QemuOptsList == NULLvl.c: fix segfault in iscsi options parsingblock/iscsi.c | 27 --------------------------- util/qemu-option.c | 1 + vl.c | 40 +++++++++++++++++++++++++++++++++++++--- 3 files changed, 38 insertions(+), 30 deletions(-)
Il 19/03/2013 20:37, Peter Lieven ha scritto:
Quoted 20 lines
Am 19.03.2013 um 18:07 schrieb Paolo Bonzini <[email protected]>:
Quoted 6 lines
Il 19/03/2013 16:54, Peter Lieven ha scritto:
Quoted 5 lines · Paolo Bonzini
Quoted 4 lines
Il 19/03/2013 09:51, Markus Armbruster ha scritto:
Quoted 1 line
Paolo, please have a look.
Why isn't it enough to call
bdrv_init_with_whitelistearlier?Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
There is no conditional logic in it, the whitelist is checked at open time.
Has anyone tested if -spice is working?
It is.
machine_initentries are processed just below the otherqemu_add_opts.Ok, if you agree I would prepare a new version of this patch set with 3 patches:
Quoted 7 lines
1) move up
brd_init_with_whitelist
2) throw an error if -iscsi is used without compile libiscsi support
3) assert that QemuOptsList != NULL to avoid further segfaults.I currently see a segfault on VM start in libiscsi with latest git. Whereas my old qemu-kvm 1.2.0 is working with the same command line and libiscsi library. As soon as I have sorted this out I will send a new patch set.
I don't think (3) is that important, but yes, that's the plan.
Paolo