From patchwork Sun Sep 11 20:35:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Rzeszutek Wilk X-Patchwork-Id: 9325579 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 B1AB76048B for ; Sun, 11 Sep 2016 20:38:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A10D7284EF for ; Sun, 11 Sep 2016 20:38:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95D7028AB5; Sun, 11 Sep 2016 20:38:24 +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, UNPARSEABLE_RELAY 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 466C5284EF for ; Sun, 11 Sep 2016 20:38:24 +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 1bjBTf-0001u7-OC; Sun, 11 Sep 2016 20:35:47 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bjBTe-0001u0-BZ for xen-devel@lists.xenproject.org; Sun, 11 Sep 2016 20:35:46 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id A4/1E-05127-120C5D75; Sun, 11 Sep 2016 20:35:45 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFLMWRWlGSWpSXmKPExsXSO6nOVVfhwNV wg5VN1hbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aBFz2MBbP5K/5sPMfawHiWu4uRi0NIoI1J YuPV+6wQzjdGiaUTlzFDOBsZJX6fPsgE4UxglLi2+x5QhoODTcBE4s0qR5C4iEAbo8S3E1vZu xg5OZgFyiQeLn7CCmILC+RLLOhczQxiswioSrzY9I8RpJdXwE3iwBYVEFNCQF7i2e16kApOAX eJjXPes4CEhYAqTvQYg4QlBAwlTj/cxjiBkW8BI8MqRo3i1KKy1CJdQyO9pKLM9IyS3MTMHF1 DA1O93NTi4sT01JzEpGK95PzcTYzAMGEAgh2MfbOcDzFKcjApifL6L7gaLsSXlJ9SmZFYnBFf VJqTWnyIUYaDQ0mC9/Q+oJxgUWp6akVaZg4wYGHSEhw8SiK8f0HSvMUFibnFmekQqVOMilLiv LIgCQGQREZpHlwbLEouMcpKCfMyAh0ixFOQWpSbWYIq/4pRnINRSZiXYz/QFJ7MvBK46a+AFj MBLX669TLI4pJEhJRUA+PSUwcbq+4FSxusvTVZNW1H2Y6PdktX/7ws5H32hu3kbZ8Kz19fwWr s/yyZW0LH2q52oZBT7oaruxyPuTu/WJ7Zen9aqS3Tk7fLAkJPeJoVpAo2fruxUdt3rXSyZ12p TZhP1/Zjp7Mv3P9ZsSNtxf76W5FbFs2Zerd+6TbFb53nGpd06Zw8v32CEktxRqKhFnNRcSIAH ol2oo0CAAA= X-Env-Sender: konrad.wilk@oracle.com X-Msg-Ref: server-7.tower-206.messagelabs.com!1473626143!58772671!1 X-Originating-IP: [141.146.126.69] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTQxLjE0Ni4xMjYuNjkgPT4gMjc3MjE4\n X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 16466 invoked from network); 11 Sep 2016 20:35:44 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-7.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 11 Sep 2016 20:35:44 -0000 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u8BKZbTi004760 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 11 Sep 2016 20:35:37 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u8BKZaiZ029008 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 11 Sep 2016 20:35:36 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u8BKZZhY030371; Sun, 11 Sep 2016 20:35:35 GMT Received: from localhost.localdomain.com (/209.6.196.81) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 11 Sep 2016 13:35:35 -0700 From: Konrad Rzeszutek Wilk To: xen-devel@lists.xenproject.org, konrad@kernel.org, julien.grall@arm.com, sstabellini@kernel.org, ross.lagerwall@citrix.com Date: Sun, 11 Sep 2016 16:35:09 -0400 Message-Id: <1473626125-13683-3-git-send-email-konrad.wilk@oracle.com> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1473626125-13683-1-git-send-email-konrad.wilk@oracle.com> References: <1473626125-13683-1-git-send-email-konrad.wilk@oracle.com> X-Source-IP: userv0021.oracle.com [156.151.31.71] Cc: andrew.cooper3@citrix.com, Jan Beulich , Konrad Rzeszutek Wilk Subject: [Xen-devel] [PATCH v3 02/18] livepatch: Reject payloads with .alternative or .ex_table if support is not built-in. 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: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP If the payload had the sections mentioned but the hypervisor did not support some of them (say on ARM the .ex_table) - instead of ignoring them - it should forbid loading of such payload. Signed-off-by: Konrad Rzeszutek Wilk Reviewed-by: Julien Grall --- Cc: Stefano Stabellini Cc: Julien Grall Cc: Jan Beulich Cc: Andrew Cooper v3: New submission. --- xen/common/livepatch.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/xen/common/livepatch.c b/xen/common/livepatch.c index a2ddb61..5baa418 100644 --- a/xen/common/livepatch.c +++ b/xen/common/livepatch.c @@ -628,10 +628,10 @@ static int prepare_payload(struct payload *payload, sizeof(*region->frame[i].bugs); } -#ifdef CONFIG_HAS_ALTERNATIVE sec = livepatch_elf_sec_by_name(elf, ".altinstructions"); if ( sec ) { +#ifdef CONFIG_HAS_ALTERNATIVE struct alt_instr *a, *start, *end; if ( sec->sec->sh_size % sizeof(*a) ) @@ -658,13 +658,17 @@ static int prepare_payload(struct payload *payload, } } apply_alternatives(start, end); - } +#else + dprintk(XENLOG_ERR, LIVEPATCH "%s: We don't support alternative patching!\n", + elf->name); + return -EOPNOTSUPP; #endif + } -#ifdef CONFIG_HAS_EX_TABLE sec = livepatch_elf_sec_by_name(elf, ".ex_table"); if ( sec ) { +#ifdef CONFIG_HAS_EX_TABLE struct exception_table_entry *s, *e; if ( !sec->sec->sh_size || @@ -683,8 +687,12 @@ static int prepare_payload(struct payload *payload, region->ex = s; region->ex_end = e; - } +#else + dprintk(XENLOG_ERR, LIVEPATCH "%s: We don't support .ex_table!\n", + elf->name); + return -EOPNOTSUPP; #endif + } return 0; }