From patchwork Thu Jun 22 18:15:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 9805083 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6D3A36086C for ; Thu, 22 Jun 2017 18:18:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66E8D24B44 for ; Thu, 22 Jun 2017 18:18:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B8642870D; Thu, 22 Jun 2017 18:18:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0A07F24B44 for ; Thu, 22 Jun 2017 18:18:00 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dO6dm-0001yI-2y; Thu, 22 Jun 2017 18:15:38 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dO6dk-0001xp-8y for xen-devel@lists.xen.org; Thu, 22 Jun 2017 18:15:36 +0000 Received: from [85.158.139.211] by server-11.bemta-5.messagelabs.com id E4/57-01733-7490C495; Thu, 22 Jun 2017 18:15:35 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmplkeJIrShJLcpLzFFi42JxWrohUted0yf SoPmPkMWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmnH9wRXGgmf8FfeP1zYwdvJ2MXJySAj4S/z8 cZsVxGYT0JfY/eITE4gtIqAucbrjIlCci4NZoItRYsGtb8wgCWGBcInbC5eygdgsAqoS35+3g Nm8Ah4SO06vZocYKidx/vhPsHpOAU+JZ/tPgtlCQDVfFj9khbDVJK71X2KH6BWUODnzCQuIzS wgIXHwxQvmCYy8s5CkZiFJLWBkWsWoUZxaVJZapGtkqZdUlJmeUZKbmJmja2hgqpebWlycmJ6 ak5hUrJecn7uJERg89QwMjDsYL2/xO8QoycGkJMq7udg7UogvKT+lMiOxOCO+qDQntfgQowwH h5IEryeHT6SQYFFqempFWmYOMIxh0hIcPEoivLEgad7igsTc4sx0iNQpRkUpcd4WkIQASCKjN A+uDRY7lxhlpYR5GRkYGIR4ClKLcjNLUOVfMYpzMCoJ884BmcKTmVcCN/0V0GImoMUvjniALC 5JREhJNTDyukl8mLCRO+nj5f+ti7lWe7n4zrqteOWN2w7fx1XZEfnxmlyT0j6d+PLh3Dp9qfP VHXvs27KWyK482v517yLl4GknYj281q+1Y4ue67R6UeWFlx7Sn5mkio7NZY1Wj+ByW7jG2c71 idmpRS9fSHZ05915tyl0sZpk+Ir/uixHff86ZmRwTxVVYinOSDTUYi4qTgQAAfcKhZgCAAA= X-Env-Sender: prvs=339760969=Andrew.Cooper3@citrix.com X-Msg-Ref: server-7.tower-206.messagelabs.com!1498155332!101778263!2 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 59787 invoked from network); 22 Jun 2017 18:15:34 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-7.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 22 Jun 2017 18:15:34 -0000 X-IronPort-AV: E=Sophos;i="5.39,373,1493683200"; d="scan'208";a="429044679" From: Andrew Cooper To: Xen-devel Date: Thu, 22 Jun 2017 19:15:28 +0100 Message-ID: <1498155329-4752-3-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1498155329-4752-1-git-send-email-andrew.cooper3@citrix.com> References: <1498155329-4752-1-git-send-email-andrew.cooper3@citrix.com> MIME-Version: 1.0 Cc: Andrew Cooper , Ross Lagerwall Subject: [Xen-devel] [PATCH for-4.9 v3 2/3] xen/livepatch: Use zeroed memory allocations for arrays X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Konrad Rzeszutek Wilk Tested-by: Konrad Rzeszutek Wilk Reviewed-by: Ross Lagerwall --- CC: Konrad Rzeszutek Wilk CC: Ross Lagerwall * 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",