From patchwork Thu Mar 17 11:08:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 12783887 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 32080C433EF for ; Thu, 17 Mar 2022 11:09:24 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.291500.494764 (Exim 4.92) (envelope-from ) id 1nUo0G-00081A-Op; Thu, 17 Mar 2022 11:09:12 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 291500.494764; Thu, 17 Mar 2022 11:09:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nUo0G-000813-LV; Thu, 17 Mar 2022 11:09:12 +0000 Received: by outflank-mailman (input) for mailman id 291500; Thu, 17 Mar 2022 11:09:11 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nUo0E-00080x-Va for xen-devel@lists.xenproject.org; Thu, 17 Mar 2022 11:09:11 +0000 Received: from esa5.hc3370-68.iphmx.com (esa5.hc3370-68.iphmx.com [216.71.155.168]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id aa206b22-a5e2-11ec-853c-5f4723681683; Thu, 17 Mar 2022 12:09:09 +0100 (CET) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: aa206b22-a5e2-11ec-853c-5f4723681683 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1647515349; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=TG5YQMxHE5nykjYo/YBIAEgsJBbW3Usf7syD2PnlbNc=; b=K6zx/Ur5rIlm6Q5pomfL60heGyMJgeC6xZOXEXs0QhUfgPVE4BDREi67 YV0ukmpHShdRilIcVMLQfCseXv1p90uCp4yLHbh1LOjLMuKkC/IKOV/2s OXj7C0Zr1OChc9SBSGeWen2bz5SCxTjT9gbx3/Bh79RPc9WXDc9ng0sdp U=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com X-SBRS: 5.1 X-MesageID: 65951484 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:vBn8darD/3mzs6ufA3DoXS86abheBmKVZRIvgKrLsJaIsI4StFCzt garIBmCMviONmugLt9xYIi18EJTsceGzoBgSQA9qC9jHi5BoJuZCYyVIHmrMnLJJKUvbq7GA +byyDXkBJppJpMJjk71atANlVEliefQAOCU5NfsYkidfyc9IMsaoU8lyrZRbrJA24DjWVvW4 Iyq+aUzBXf+s9JKGjNMg068gEsHUMTa4Fv0aXRnOJinFHeH/5UkJMp3yZOZdhMUcaENdgKOf M7RzanRw4/s10xF5uVJMFrMWhZirrb6ZWBig5fNMkSoqkAqSicais7XOBeAAKv+Zvrgc91Zk b1wWZKMpQgBOouPkeY/SDhhSQJ5YPVGypqceF+wiJnGp6HGWyOEL/RGCUg3OcsT+/ptAHEI/ vsdQNwPRknd3aTsmuv9E7QywJR4RCXoFNp3VnVI1zbWAOxgWZnea67L+cVZzHE7gcUm8fP2O ZdINGMzPEiojxtnHHErBbcimveThlqkemJa+W62gJpsyj2GpOB2+Oe0a4eEEjCQfu1rmUKfq nP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Q4biiieiyzlv523XI55pbtdP9wp9oBdCKiOISNjLw4zzYLbhJavmnhnQYseuv4FElnJ 3lpAohBd167zfrcmS8sXLWqnzd+Qdrz0Wn5U6TgHPlr8C8bik9EdB9iYVQdQacw1Y8vflnuZ g7kl6xht5yN1ftjS7979/HW1VBjUyvu0cvluYVkjh2TZYeUrlMtoYSlXklWqvoJBiKp7zPLd MeQv01vJ1tABKnhjHizyJSKeWXLzgO9kzseDlDhiSXuwIm7kyRgXFoh/D3pU1wha7Ve6M0md gsDZ4Y5I2mNvVmFZ6VJN1xNfdfWVa9Ni4lDgqpUCfa/ec8SjDwl6I= X-IronPort-AV: E=Sophos;i="5.90,188,1643691600"; d="scan'208";a="65951484" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cyekEL87368FuB8UB90/IQwHo9I2ed9PAnTsKq3SiqeiPZN/Jyc/Lra0sWTVqJTAfcOIfeuh4qy70I3r/CntMuX+mVCorwFpNRRbFrywue/t6i3vO6ANFHXhXwH1+a2ysPSFubdSgmn2JX1Hsn2GoqdGbHxjshRV6JN/xcfNvWYv3sKe2Xqz3phEpjjLeFgFgn5NA21z5XiRfT6EGMyvHm87Rm93vBcvPHhpuneSl5uG9u6ls9G5re5J0vXPUsiYN1psu0rgEgeNGg1NQRMEoJVQemiSXlO/MApOKakeUgJC1WHcZcMB5h/0eHzjYp2cVo0RGNkcuTHzXN+Der9tlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4ZvNQ2Jsd1nbrbGwaI4yAv5SLDZE/R4NZJGlJk5r62U=; b=PV1wIZ19MRKiAH3ZJdtjVPX8e8HdzQOdrkF1ZWpKG2tA3qOXpMNGS3zKtkV8J4qo5snv5BsfoROM6PvuyUukHzOZfGsudinXXbEMzH8CSpIkFyuYTEOAzb7T4WNgtLPfLySh+eCqzenrBxm7XlF0Y63zI7KtisrUY5p9+2Z1TN8wZ/eagLexNUgZGR/aNymHWKsaiK5a9XyMCP6LbKSjmZnHPqWMxX229YTh0KPLRgSbZGOF+DNqvc8l/HGi3ap+iAwYSHUV5Q+6fBm2beXCLZ+sCLbm9BtS+jFO6FB9OPsOPuTLf8aJMaNQzm7W6q1L6f3xJrM1Eexb/hkhkGRi/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4ZvNQ2Jsd1nbrbGwaI4yAv5SLDZE/R4NZJGlJk5r62U=; b=Zh9spOnXbWkBQ5WjIEmHaCukLuS2HnD2mZFbDuhsxKRILQobpChvGr3XGrG1iG1ikfhBiWhyISu0EPnyIoaddyKEsxAacXgbTahCvnvNld8Z852VGMPp7f9cOZ3POieol1xglQ+35UB9mAGY4chqalafGpSSeDv3d6gm+DyoDQw= From: Roger Pau Monne To: CC: Roger Pau Monne , Konrad Rzeszutek Wilk , Ross Lagerwall , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk , Jan Beulich , Andrew Cooper , Wei Liu Subject: [PATCH 0/2] livepatch: fix handling of (some) relocations Date: Thu, 17 Mar 2022 12:08:52 +0100 Message-ID: <20220317110854.39050-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: LO4P123CA0060.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:153::11) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ead39772-0926-46fc-2b49-08da08068c48 X-MS-TrafficTypeDiagnostic: BL1PR03MB6102:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JSsGPzoStBvFQQuZxGquA/+fhiGprAU7UGrlKJexAotQlkkY+bKi3UCWwx82afd7vBPqWAOnf4QTqNsD/ovQqS+WcjDNjd0iLMcLbOIfn3jAc2KQikFNosSPwPXFP2MUef+c5IJFTejSN6KX7BsitT3IGbxubn2M3Nlf0MAZ1IJn1WGmEAEoW4hYIFdkQJn7RPhe41Rsl1nkLBqcHt2icOUuIV3BuIhhc6+oRzPfNAw0SWaUvkOSmDv3+qTa38DvJ9GkJsY4ayWt7YdrRZ4Lgl3y1t2bmIbrEuW6+jAjUvAYG+SYo+F+eB37aB7seLnnB/UMcZ17/lvVxmW24dbmh/v2NnUenBfnshsub4UHfxAx13Cwr1wQxYNeFSX3gY++cUmHxucQVLg12IQuREfJurHzNl3NAMQK1ao8v5/40WV55gM2g2fZ7f8e+Ce/zBiskkPCPQP6v/wmZN6Qg/RmeGPBzg77Pt6cmELZYEUo4H+ojLFNjKS0qq+1UawlUSCFlXhyWY/dZzvmAK//P3zJB8/lcyknGmj0Xrp96uT0eGS29vdzsTOMLjkfMnTX5IcCl1T6IdjB+l12qDO/AwYFePhPOdmTTIRETSDweaXdy58pX7nXMlXqBeE8KAcF+Ue37i7OWYQC8WvhxsEP0htXuQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(83380400001)(2906002)(4326008)(508600001)(8676002)(82960400001)(6512007)(86362001)(6506007)(5660300002)(6666004)(6916009)(8936002)(26005)(66946007)(66476007)(316002)(66556008)(186003)(36756003)(2616005)(6486002)(38100700002)(1076003)(54906003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?08wkmDbF6uQmknTffOUkRCgUFRWm?= =?utf-8?q?U78Sp41Su6PiI4b9aJ8coLBU7uuC6yvW5h+JkEwJ0uPdLDKHHRwqhQTH+gXx48H2N?= =?utf-8?q?/YugJJrrEt67BirRxpqzWud6y1YP+ftXaB/m54FwCgs3chQiP4Uwj0qTlgGhnNxni?= =?utf-8?q?jf7vtdOzMavRRRSDfjrXjCb2nPZ+3Ygvi3yKI/C3HsLrEapH3UsYyhQu9F1ZS2Qsb?= =?utf-8?q?ubT6Nde5aVy3AhN7qLBG+FvIuARElAudXTRg4wq+/mFEInfat7EhqMT/zskENdWmC?= =?utf-8?q?wo4UFLazPOeuk1vKpuLkFq0TaxHAwpLYkWLT11QLbyKmhflAfkb9HMVNxA+yh8BmQ?= =?utf-8?q?PgEatgDWg1E2+ePcYBS2vHh1qOZko6SdnDgEKhe7RXSzeN895CT7+USKkRwt/QRAv?= =?utf-8?q?cqRQhOk899CX5rGMYZXZFEBe9hW9GEIzxrWdubqMfGiQvD0k9WIcWbQ0QZ7jXVdik?= =?utf-8?q?BxU7mzAOJFi+xRsjnAxqHv4pn0z3b6cxt+FaIU0Ar5tH/roV3fVTxm8mQaobjvo3e?= =?utf-8?q?QAOug+nEIwW8PKZIAunKwib6I3J6KGPHZjfx/+W7KkbxVq64TwlT/LbmSf28Y9gQE?= =?utf-8?q?Y21bMBnP4g0AsiASm8dXVODz0OGkU93Q6FOJ/Lp5V/MBZKo80h/nABPF/dkM5OO0Q?= =?utf-8?q?0iNmeo4+eCTF/7YT4GBbcieDDIXh0kw5jzPZJuZI5aV6JyKwrFMkxroymuIioBROI?= =?utf-8?q?BWZWNPnIwhMibXjPa+M+AQ6yC8jcweGXirFWAjkNN7LkqMeQ+CsYvpQYezSRHal7m?= =?utf-8?q?ROFAMIViz96yuitEXPQtBhBJV+6+PTamcV9D9bIXzw+HWRSvnvQqrR2d+oFH1vPHK?= =?utf-8?q?NtVD3ghdGVrOLwGgsY7jHiLStYofyEBXfAx8iwKG8+KPp/dVGFAyqqtygu/oEL1qh?= =?utf-8?q?AXlpWULguGm8SlgkLNjXrTAVLlvougw+Qr4dYkHwIrRJaoMXvYBfR7Mfl/9q3Tcrj?= =?utf-8?q?YQ3kMMlKNCAKh7nsG+tQtz5mhHGt480Xr80OEUPsmbyCt17AFGAGWI9vmuMJi0rnB?= =?utf-8?q?VEL6mAWDrEJ0jd3Y8LQzrdeCTAm3M/Ijl/vZDEJIDhjB2tbuzqkLu51hIYXTq+q9w?= =?utf-8?q?5yvOeynm5JqBulRTgMBrk0+0Yh7YsnpegtXGEB1XlWmr1PBlLCg6NeEhlGHp9RFhU?= =?utf-8?q?2hd56EwJOgyVkOaFLg1ze8cWbuu14z6ZNySCM8MFyiiKg3c/VgjIyceLAmPN+VB9Y?= =?utf-8?q?dD1uMkskx13maZkeE52WplQ8OMlp1Y3HleX2FTUZmMMCnvBYBVo8/+rMW+yupAI95?= =?utf-8?q?AdbAFGzUfObpls1BO4h/8QleCVhXhf76xuQVQSxakosHZ/XTsIZoArITj6u/vJfMO?= =?utf-8?q?Q/lFshjM6Sj/Fq6c+OTmPopTtkNmEemQXL0oT9NXLNmpfNf4froDkd7neuut7KCOp?= =?utf-8?q?5YFsH3NGZkRV7KTTj3N1jZ1ul5IiKAHNHIBA=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: ead39772-0926-46fc-2b49-08da08068c48 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Mar 2022 11:09:04.4273 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: CTim6WTVEimnR/BD48wYUwDvo7UcAohI52jatw+gwtR++L4KNMl8PWlmSLnDl5z8FzRjckAeRpQToqTEYM1okg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR03MB6102 X-OriginatorOrg: citrix.com Hello, Relocations that reference symbols that belong to sections with a size of 0 are not properly resolved, as the address of those symbols won't be resolved in the first place. Fix this by not ignoring sections with a size of 0, while still properly handling the detection of whether a livepatch can be reapplied after being reverted (patch 1). Also detect whether any relocations reference unresolved symbols and error out in that case, as those relocations cannot be resolved (patch 2). I wonder whether it's possible to have unresolved symbols if we only ignore non SHF_ALLOC sections, so we could maybe error out earlier if we found a symbols that belongs to a non SHF_ALLOC section in livepatch_elf_resolve_symbols. The current approach is more conservative as we would only report an error if we have unresolved symbols that are referenced in relocations. Thanks, Roger. Roger Pau Monne (2): livepatch: do not ignore sections with 0 size livepatch: avoid relocations referencing ignored section symbols xen/arch/arm/arm32/livepatch.c | 7 +++++++ xen/arch/arm/arm64/livepatch.c | 7 +++++++ xen/arch/x86/livepatch.c | 7 +++++++ xen/common/livepatch.c | 16 +++++++++++----- xen/common/livepatch_elf.c | 6 ++++++ xen/include/xen/livepatch_elf.h | 3 ++- 6 files changed, 40 insertions(+), 6 deletions(-)