From: Chunyan Liu <cyliu@suse.com>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
Ian Campbell <Ian.Campbell@citrix.com>
Subject: Re: question about SIGSEGV in datacopier_readable in libxl_aoutil.c [and 1 more messages]
Date: Wed, 4 Sep 2013 16:15:11 +0800 [thread overview]
Message-ID: <CAERYnoZEBHf=SYuj2FRggQ0gxLpgG2C-F5NrcyqGVfPjLi2chQ@mail.gmail.com> (raw)
In-Reply-To: <21029.62118.393604.371370@mariner.uk.xensource.com>
[-- Attachment #1.1: Type: text/plain, Size: 2102 bytes --]
2013/9/3 Ian Jackson <Ian.Jackson@eu.citrix.com>
> Ian Campbell writes ("Re: [Xen-devel] question about SIGSEGV in
> datacopier_readable in libxl_aoutil.c"):
> > On Tue, 2013-09-03 at 15:01 +0800, Chunyan Liu wrote:
> > > if (!buf || buf->used >= sizeof(buf->buf)) {
> > > buf = malloc(sizeof(*buf));
> ...
> > > ==7510== Syscall param read(buf) points to unaddressable byte(s)
> ...
> > > ==7510== Address 0x18a409ec is 0 bytes after a block of size 28
> alloc'd
> > > ==7510== at 0x4C26FFB: calloc (in
> /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
> > > ==7510== by 0x14AAECB6: libxl__zalloc (libxl_internal.c:83)
> > > ==7510== by 0x14AB33B0: libxl__datacopier_prefixdata
> (libxl_aoutils.c:92)
>
> I think this is my fault. Please try this patch.
>
> Thanks,
> Ian.
>
> commit 25cd65c97b733d5892b62c3ffae0887f426398ec
> Author: Ian Jackson <ian.jackson@eu.citrix.com>
> Date: Tue Sep 3 13:41:46 2013 +0100
>
> libxl: Do not generate short block in libxl__datacopier_prefixdata
>
> libxl__datacopier_prefixdata would prepend a deliberately short block
> (not just a half-full one, but one with a short buffer) to the
> dc->bufs queue. However, this is wrong because datacopier_readable
> will find it and try to continue to fill it up.
>
> Instead, allocate a full-sized buffer.
>
> Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
>
> diff --git a/tools/libxl/libxl_aoutils.c b/tools/libxl/libxl_aoutils.c
> index 983a60a..b4eb6e5 100644
> --- a/tools/libxl/libxl_aoutils.c
> +++ b/tools/libxl/libxl_aoutils.c
> @@ -89,7 +89,7 @@ void libxl__datacopier_prefixdata(libxl__egc *egc,
> libxl__datacopier_state *dc,
>
> assert(len < dc->maxsz - dc->used);
>
> - buf = libxl__zalloc(NOGC, sizeof(*buf) - sizeof(buf->buf) + len);
> + buf = libxl__zalloc(NOGC, sizeof(*buf));
> buf->used = len;
> memcpy(buf->buf, data, len);
>
>
Tried the patch. It worked. Thanks.
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
>
>
[-- Attachment #1.2: Type: text/html, Size: 3084 bytes --]
[-- Attachment #2: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
prev parent reply other threads:[~2013-09-04 8:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-03 7:01 question about SIGSEGV in datacopier_readable in libxl_aoutil.c Chunyan Liu
2013-09-03 7:56 ` Ian Campbell
2013-09-03 9:23 ` Andrew Cooper
2013-09-03 14:31 ` question about SIGSEGV in datacopier_readable in libxl_aoutil.c [and 1 more messages] Ian Jackson
2013-09-04 8:15 ` Chunyan Liu [this message]
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='CAERYnoZEBHf=SYuj2FRggQ0gxLpgG2C-F5NrcyqGVfPjLi2chQ@mail.gmail.com' \
--to=cyliu@suse.com \
--cc=Ian.Campbell@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=xen-devel@lists.xensource.com \
/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).