From patchwork Fri Feb 12 18:05:56 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: 8294951 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BDE379F6E4 for ; Fri, 12 Feb 2016 18:09:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EF7052042C for ; Fri, 12 Feb 2016 18:09:26 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3ADAD2041D for ; Fri, 12 Feb 2016 18:09:25 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aUI7S-00069z-Ic; Fri, 12 Feb 2016 18:07:02 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aUI7K-00064S-S7 for xen-devel@lists.xen.org; Fri, 12 Feb 2016 18:06:54 +0000 Received: from [85.158.139.211] by server-1.bemta-5.messagelabs.com id 80/90-15353-E3F1EB65; Fri, 12 Feb 2016 18:06:54 +0000 X-Env-Sender: konrad@char.us.oracle.com X-Msg-Ref: server-16.tower-206.messagelabs.com!1455300412!21761017!1 X-Originating-IP: [156.151.31.81] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTU2LjE1MS4zMS44MSA9PiAyODgzMzk=\n X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 34969 invoked from network); 12 Feb 2016 18:06:53 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-16.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 12 Feb 2016 18:06:53 -0000 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u1CI6isc004483 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Feb 2016 18:06:44 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.13.8) with ESMTP id u1CI6i09006128 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 12 Feb 2016 18:06:44 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u1CI6hsm017149; Fri, 12 Feb 2016 18:06:43 GMT Received: from char.us.oracle.com (/10.137.176.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 12 Feb 2016 10:06:43 -0800 Received: by char.us.oracle.com (Postfix, from userid 1000) id 0BC286A4BF2; Fri, 12 Feb 2016 13:06:41 -0500 (EST) From: Konrad Rzeszutek Wilk To: xen-devel@lists.xenproject.org, andrew.cooper3@citrix.com, konrad@kernel.org, mpohlack@amazon.de, ross.lagerwall@citrix.com, sasha.levin@citrix.com, jinsong.liu@alibaba-inc.com, Ian Campbell , Ian Jackson , Jan Beulich , Keir Fraser , Tim Deegan , xen-devel@lists.xen.org Date: Fri, 12 Feb 2016 13:05:56 -0500 Message-Id: <1455300361-13092-19-git-send-email-konrad.wilk@oracle.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1455300361-13092-1-git-send-email-konrad.wilk@oracle.com> References: <1455300361-13092-1-git-send-email-konrad.wilk@oracle.com> X-Source-IP: userv0022.oracle.com [156.151.31.74] Cc: Konrad Rzeszutek Wilk Subject: [Xen-devel] [PATCH v3 18/23] xsplice: Prevent duplicate payloads to be loaded. X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ross Lagerwall Signed-off-by: Ross Lagerwall Signed-off-by: Konrad Rzeszutek Wilk --- xen/common/xsplice.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/xen/common/xsplice.c b/xen/common/xsplice.c index 8c5557e..3f1da13 100644 --- a/xen/common/xsplice.c +++ b/xen/common/xsplice.c @@ -728,6 +728,23 @@ static int find_special_sections(struct payload *payload, if ( xen_build_id_check(&payload->id.p, &payload->id.len, n) ) return -EINVAL; } + /* Make sure it is not a duplicate. */ + if ( payload->id.len ) + { + struct payload *data; + + spin_lock(&payload_lock); + list_for_each_entry ( data, &payload_list, list ) + { + if ( data != payload && data->id.len && + !memcmp(data->id.p, payload->id.p, data->id.len) ) + { + spin_unlock(&payload_lock); + return -EEXIST; + } + } + spin_unlock(&payload_lock); + } sec = xsplice_elf_sec_by_name(elf, ".xsplice.depends"); {