xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Dave Scott <Dave.Scott@citrix.com>
To: Andrew Cooper <Andrew.Cooper3@citrix.com>
Cc: Xen-devel <xen-devel@lists.xenproject.org>,
	Dave Scott <Dave.Scott@citrix.com>, Wei Liu <wei.liu2@citrix.com>,
	Ian Campbell <Ian.Campbell@citrix.com>,
	Ian Jackson <Ian.Jackson@citrix.com>
Subject: Re: [PATCH for-4.6 13/13] tools/ocaml: handle strdup failure in stub_xl_device_disk_of_vdev
Date: Thu, 23 Jul 2015 09:12:44 +0000	[thread overview]
Message-ID: <852A5149-6939-48FE-AEDE-A575A9C17AF2@citrix.com> (raw)
In-Reply-To: <55B0A80A.8080702@citrix.com>


> On 23 Jul 2015, at 09:38, Andrew Cooper <andrew.cooper3@citrix.com> wrote:
> 
> On 23/07/2015 08:59, Wei Liu wrote:
>> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
>> ---
>> Cc: dave.scott@eu.citrix.com
>> 
>> Please check if the use of caml_failwith is correct.
> 
> This issue I have a different patch for, which could be 4.6 material, if
> it weren't for the same issue as identified in patch 12.
> 
> In this case, Ocaml strings may contain embedded NULs which generally
> makes the use of  the strxxx() functions incorrect.  OTOH, the first
> thing libxl will do is assume that they are NUL terminated, so it
> probably isn't too much of a problem.

Yeah I would assume if my OCaml program sent libxl a legal OCaml string containing NULLs, that libxl would end up truncating it at the first NULL. I think it would be ok to document this at the OCaml level.

Cheers,
Dave

> 
> There is already a dup_String_Val() function which attempts to deal with
> this, although it has failure cases from integer overflows.
> 
> ~Andrew
> 
>> ---
>> tools/ocaml/libs/xl/xenlight_stubs.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>> 
>> diff --git a/tools/ocaml/libs/xl/xenlight_stubs.c b/tools/ocaml/libs/xl/xenlight_stubs.c
>> index 7b8d6db..dccd7ed 100644
>> --- a/tools/ocaml/libs/xl/xenlight_stubs.c
>> +++ b/tools/ocaml/libs/xl/xenlight_stubs.c
>> @@ -780,6 +780,10 @@ value stub_xl_device_disk_of_vdev(value ctx, value domid, value vdev)
>> 
>> 	c_vdev = strdup(String_val(vdev));
>> 
>> +	if (!c_vdev) {
>> +		caml_failwith("Failed to duplicate vdev string.");
>> +	}
>> +
>> 	caml_enter_blocking_section();
>> 	libxl_vdev_to_device_disk(CTX, c_domid, c_vdev, &c_disk);
>> 	caml_leave_blocking_section();
> 

  reply	other threads:[~2015-07-23  9:19 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-23  7:59 [PATCH for-4.6 00/13] tools: fixes inspired by Coverity scan Wei Liu
2015-07-23  7:59 ` [PATCH for-4.6 01/13] libxl: use thread-safe localtime_t and handle NULL Wei Liu
2015-07-23  9:14   ` Ian Campbell
2015-07-23  9:34     ` Wei Liu
2015-07-23  7:59 ` [PATCH for-4.6 02/13] libxl: properly clean up array in libxl_list_cpupool failure path Wei Liu
2015-07-23  9:22   ` Ian Campbell
2015-07-23 14:29     ` Dario Faggioli
2015-07-23  7:59 ` [PATCH for-4.6 03/13] xl/libxl: remove a bunch of pointless assignments Wei Liu
2015-07-23  9:25   ` Ian Campbell
2015-07-23  7:59 ` [PATCH for-4.6 04/13] xl: free pid string in do_daemonize Wei Liu
2015-07-23  9:34   ` Ian Campbell
2015-07-23  7:59 ` [PATCH for-4.6 05/13] xl: check json string is not null before printing in create_domain Wei Liu
2015-07-23  9:36   ` Ian Campbell
2015-07-23  7:59 ` [PATCH for-4.6 06/13] xl: call libxl_dominfo_{init, dispose} in psr_cmt_show Wei Liu
2015-07-23  9:36   ` Ian Campbell
2015-07-23  7:59 ` [PATCH for-4.6 07/13] xl: call libxl_dominfo_{init, dispose} in main_cpupoolnumasplit Wei Liu
2015-07-23  9:41   ` Ian Campbell
2015-07-23 10:34     ` Wei Liu
2015-07-23  7:59 ` [PATCH for-4.6 08/13] xl: call libxl_dominfo_init in main_list Wei Liu
2015-07-23  9:44   ` Ian Campbell
2015-07-23  7:59 ` [PATCH for-4.6 09/13] xl: call libxl_bitmap_{init, dispose} in main_cpupoolcreate Wei Liu
2015-07-23  9:46   ` Ian Campbell
2015-07-23  7:59 ` [PATCH for-4.6 10/13] xl: valid fd can be 0 in main_loadpolicy Wei Liu
2015-07-23  9:48   ` Ian Campbell
2015-07-23  7:59 ` [PATCH for-4.6 11/13] xl: free event struct after use in main_shutdown_or_reboot Wei Liu
2015-07-23  9:52   ` Ian Campbell
2015-07-23  7:59 ` [PATCH for-4.6 12/13] tools/ocaml: call libxl_dominfo_{init, dispose} in stub Wei Liu
2015-07-23  8:32   ` Andrew Cooper
2015-07-23  8:38     ` Wei Liu
2015-07-23  9:07       ` Andrew Cooper
2015-07-23  9:55     ` Ian Campbell
2015-07-23 10:00       ` Andrew Cooper
2015-07-23  7:59 ` [PATCH for-4.6 13/13] tools/ocaml: handle strdup failure in stub_xl_device_disk_of_vdev Wei Liu
2015-07-23  8:38   ` Andrew Cooper
2015-07-23  9:12     ` Dave Scott [this message]
2015-07-23  9:06   ` Dave Scott
2015-07-24 11:06 ` [PATCH for-4.6 00/13] tools: fixes inspired by Coverity scan Ian Campbell

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=852A5149-6939-48FE-AEDE-A575A9C17AF2@citrix.com \
    --to=dave.scott@citrix.com \
    --cc=Andrew.Cooper3@citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=Ian.Jackson@citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).