From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Ross Lagerwall <ross.lagerwall@citrix.com>,
Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH for-4.9 v3 2/3] xen/livepatch: Use zeroed memory allocations for arrays
Date: Thu, 22 Jun 2017 22:55:19 -0400 [thread overview]
Message-ID: <20170623025519.GA16590@char.us.oracle.com> (raw)
In-Reply-To: <1498155329-4752-3-git-send-email-andrew.cooper3@citrix.com>
On Thu, Jun 22, 2017 at 07:15:28PM +0100, Andrew Cooper wrote:
> Each of these arrays is sparse. Use zeroed allocations to cause uninitialised
> array elements to contain deterministic values, most importantly for the
> embedded pointers.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tested-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
[x86 and ARM32]
> CC: Ross Lagerwall <ross.lagerwall@citrix.com>
>
> * new in v3
> ---
> xen/common/livepatch.c | 4 ++--
> xen/common/livepatch_elf.c | 4 ++--
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/xen/common/livepatch.c b/xen/common/livepatch.c
> index df67a1a..66d532d 100644
> --- a/xen/common/livepatch.c
> +++ b/xen/common/livepatch.c
> @@ -771,8 +771,8 @@ static int build_symbol_table(struct payload *payload,
> }
> }
>
> - symtab = xmalloc_array(struct livepatch_symbol, nsyms);
> - strtab = xmalloc_array(char, strtab_len);
> + symtab = xzalloc_array(struct livepatch_symbol, nsyms);
> + strtab = xzalloc_array(char, strtab_len);
>
> if ( !strtab || !symtab )
> {
> diff --git a/xen/common/livepatch_elf.c b/xen/common/livepatch_elf.c
> index c4a9633..b69e271 100644
> --- a/xen/common/livepatch_elf.c
> +++ b/xen/common/livepatch_elf.c
> @@ -52,7 +52,7 @@ static int elf_resolve_sections(struct livepatch_elf *elf, const void *data)
> int rc;
>
> /* livepatch_elf_load sanity checked e_shnum. */
> - sec = xmalloc_array(struct livepatch_elf_sec, elf->hdr->e_shnum);
> + sec = xzalloc_array(struct livepatch_elf_sec, elf->hdr->e_shnum);
> if ( !sec )
> {
> dprintk(XENLOG_ERR, LIVEPATCH"%s: Could not allocate memory for section table!\n",
> @@ -225,7 +225,7 @@ static int elf_get_sym(struct livepatch_elf *elf, const void *data)
> /* No need to check values as elf_resolve_sections did it. */
> nsym = symtab_sec->sec->sh_size / symtab_sec->sec->sh_entsize;
>
> - sym = xmalloc_array(struct livepatch_elf_sym, nsym);
> + sym = xzalloc_array(struct livepatch_elf_sym, nsym);
> if ( !sym )
> {
> dprintk(XENLOG_ERR, LIVEPATCH "%s: Could not allocate memory for symbols\n",
> --
> 2.1.4
>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-06-23 2:55 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-22 18:15 [PATCH for-4.9 v3 0/3] Fixes for livepatching Andrew Cooper
2017-06-22 18:15 ` [PATCH for-4.9 v3 1/3] xen/livepatch: Clean up arch relocation handling Andrew Cooper
2017-06-22 18:15 ` [PATCH for-4.9 v3 2/3] xen/livepatch: Use zeroed memory allocations for arrays Andrew Cooper
2017-06-23 2:55 ` Konrad Rzeszutek Wilk [this message]
2017-06-23 12:31 ` Ross Lagerwall
2017-06-22 18:15 ` [PATCH for-4.9 v3 3/3] xen/livepatch: Don't crash on encountering STN_UNDEF relocations Andrew Cooper
2017-06-22 21:10 ` Stefano Stabellini
2017-06-23 2:56 ` Konrad Rzeszutek Wilk
2017-06-23 9:50 ` Jan Beulich
2017-06-23 10:13 ` Andrew Cooper
2017-06-23 12:35 ` Ross Lagerwall
2017-06-23 13:32 ` Julien Grall
2017-06-23 13:33 ` Andrew Cooper
2017-06-23 13:43 ` Julien Grall
2017-06-23 13:45 ` Andrew Cooper
2017-06-23 13:47 ` Julien Grall
2017-06-23 14:35 ` Konrad Rzeszutek Wilk
2017-06-23 14:36 ` Julien Grall
2017-06-23 14:46 ` Konrad Rzeszutek Wilk
2017-06-24 17:28 ` Julien Grall
2017-06-26 1:02 ` Konrad Rzeszutek Wilk
2017-06-26 9:34 ` Julien Grall
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=20170623025519.GA16590@char.us.oracle.com \
--to=konrad.wilk@oracle.com \
--cc=andrew.cooper3@citrix.com \
--cc=ross.lagerwall@citrix.com \
--cc=xen-devel@lists.xen.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).