From: Liam Merwick <liam.merwick@oracle.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: qemu-devel@nongnu.org, pbonzini@redhat.com, ehabkost@redhat.com,
rth@twiddle.net, xen-devel@lists.xenproject.org,
sgarzare@redhat.com, mst@redhat.com, maran.wilson@oracle.com,
george.kennedy@oracle.com, boris.ostrovsky@oracle.com
Subject: Re: [Qemu-devel] [RFC v2 1/4] elf: Add optional function ptr to load_elf() to parse ELF notes
Date: Tue, 8 Jan 2019 14:47:43 +0000 [thread overview]
Message-ID: <896d7d97-f79e-25e8-0bae-47bc5725fe35@oracle.com> (raw)
In-Reply-To: <20190102130650.GM24009@stefanha-x1.localdomain>
On 02/01/2019 13:06, Stefan Hajnoczi wrote:
> On Fri, Dec 21, 2018 at 08:03:49PM +0000, Liam Merwick wrote:
>> diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h
>> index 74679ff8da3a..37d20a3800c1 100644
>> --- a/include/hw/elf_ops.h
>> +++ b/include/hw/elf_ops.h
>> @@ -266,6 +266,7 @@ fail:
>> }
>>
>> static int glue(load_elf, SZ)(const char *name, int fd,
>> + uint64_t (*elf_note_fn)(void *, void *, bool),
>> uint64_t (*translate_fn)(void *, uint64_t),
>> void *translate_opaque,
>> int must_swab, uint64_t *pentry,
>> @@ -496,8 +497,30 @@ static int glue(load_elf, SZ)(const char *name, int fd,
>> high = addr + mem_size;
>>
>> data = NULL;
>> +
>> + } else if (ph->p_type == PT_NOTE && elf_note_fn) {
>> + struct elf_note *nhdr = NULL;
>> +
>> + file_size = ph->p_filesz; /* Size of the range of ELF notes */
>> + data = g_malloc0(file_size);
>> + if (ph->p_filesz > 0) {
>> + if (lseek(fd, ph->p_offset, SEEK_SET) < 0) {
>> + goto fail;
>> + }
>> + if (read(fd, data, file_size) != file_size) {
>> + goto fail;
>> + }
>> + }
>> +
>> + if (nhdr != NULL) {
>> + bool is64 =
>> + sizeof(struct elf_note) == sizeof(struct elf64_note);
>> + elf_note_fn((void *)nhdr, (void *)&ph->p_align, is64);
>
> How does data get used?
Moved (as suggested in comments for next patch)
>
>> + }
>> + g_free(data);
>
> Missing data = NULL to prevent double free later?
>
Added explicit assignment.
Regards,
Liam
next prev parent reply other threads:[~2019-01-08 14:48 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-21 20:03 [Qemu-devel] [RFC v2 0/4] QEMU changes to do PVH boot Liam Merwick
2018-12-21 20:03 ` [Qemu-devel] [RFC v2 1/4] elf: Add optional function ptr to load_elf() to parse ELF notes Liam Merwick
2019-01-02 13:06 ` Stefan Hajnoczi
2019-01-08 14:47 ` Liam Merwick [this message]
2018-12-21 20:03 ` [Qemu-devel] [RFC v2 2/4] elf-ops.h: Add get_elf_note_type() Liam Merwick
2019-01-02 13:12 ` Stefan Hajnoczi
2019-01-08 14:47 ` Liam Merwick
2018-12-21 20:03 ` [Qemu-devel] [RFC v2 3/4] pvh: Add x86/HVM direct boot ABI header file Liam Merwick
2018-12-21 20:03 ` [Qemu-devel] [RFC v2 4/4] pvh: Boot uncompressed kernel using direct boot ABI Liam Merwick
2019-01-02 13:18 ` Stefan Hajnoczi
2019-01-08 14:48 ` Liam Merwick
2018-12-26 17:08 ` [Qemu-devel] [RFC v2 0/4] QEMU changes to do PVH boot no-reply
2019-01-03 17:22 ` Stefano Garzarella
2019-01-08 14:47 ` Liam Merwick
2019-01-09 11:53 ` Stefano Garzarella
2019-01-09 19:53 ` Boris Ostrovsky
2019-01-09 21:18 ` Maran Wilson
2019-01-10 15:12 ` Stefano Garzarella
2019-01-15 9:51 ` Liam Merwick
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=896d7d97-f79e-25e8-0bae-47bc5725fe35@oracle.com \
--to=liam.merwick@oracle.com \
--cc=boris.ostrovsky@oracle.com \
--cc=ehabkost@redhat.com \
--cc=george.kennedy@oracle.com \
--cc=maran.wilson@oracle.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
--cc=sgarzare@redhat.com \
--cc=stefanha@redhat.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).