Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3299672imm; Fri, 19 Oct 2018 08:21:58 -0700 (PDT) X-Google-Smtp-Source: ACcGV60E47qdQ/PqFb/xYAuO8YPSieM086y5ejCo04mm4RvxU3OTJtm/tKy8qOImL5pNcHcOPvw3 X-Received: by 2002:a17:902:7e0b:: with SMTP id b11-v6mr34146137plm.246.1539962518268; Fri, 19 Oct 2018 08:21:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539962518; cv=none; d=google.com; s=arc-20160816; b=g8qGoda7Hd9ucEvUIVRQNK5dRLvKATE3/Kv/ITQ8i1JdgacdNS6Q9TubMjLXSVEn6E jIrz53u5BE7Ln445LBe1T7uezqnrwOKmxR/Ul+Guwfux6G5U8HMVomXuXl64yQvU2zt/ O5FY1YORSJjEZth6ONoeccTy6TrcRGpplpDbyLlYjNfgsdtqTtGfUADW5FnCoobhW2cI q+ZGwoVmSQ1YgKz+j+0NXV2WwWtgux2BGft9iIgA8VzuSmJPZhJxxWvIlZexTJg5HlMx 6S0xby0n2Grwh4tOv4B8f4Nqfu4XjopS2VRniD8OWrfNcMUPt2UBy5dsvTs9wFgx2XMM LJsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=GrhTui1AePRQq8xNv0yTViVltSTwvn5QGkKoW4w+2Sg=; b=EnWnQZKTA6/f6QzzBQh1l5+CHRTD0xfcGqFSEUeRwoM2RWwwzx7fNIQ+HMBfiQvuNI KdUB6q6qnk82jaH/K0PRCKmmKFONXfCrsj0CHsPYM/3owDtK/yCOU8O8lwgm6GHazMBd R3HEvl9TPHAk6F1rVr2tcsPuaK1wMuxtQzaPatVilrtG9WluGQE/KJerc+2D9ndf85ez +9uuJQGTtM3rm7HnVhEA2zjK/ufhw5bWkae9u/L/cWAQ9aEbv/tUf1i2ckMEfJDhIchh zF4zsyhFSmida52TyYZpYN0tzXsCtxsHpiaH1rA1yzvN55KIpr43DyN+Qzvc/QnSi4/a BdFw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r9-v6si24334931pgi.569.2018.10.19.08.21.41; Fri, 19 Oct 2018 08:21:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726982AbeJSX1v (ORCPT + 99 others); Fri, 19 Oct 2018 19:27:51 -0400 Received: from mx2.suse.de ([195.135.220.15]:52038 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726667AbeJSX1v (ORCPT ); Fri, 19 Oct 2018 19:27:51 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 807DFB010; Fri, 19 Oct 2018 15:21:16 +0000 (UTC) Date: Fri, 19 Oct 2018 17:21:15 +0200 (CEST) From: Miroslav Benes To: Ard Biesheuvel cc: Jessica Yu , Torsten Duwe , Will Deacon , Catalin Marinas , Julien Thierry , Steven Rostedt , Josh Poimboeuf , Ingo Molnar , Arnd Bergmann , AKASHI Takahiro , linux-arm-kernel , Linux Kernel Mailing List , live-patching@vger.kernel.org Subject: Re: [PATCH v3 3/4] arm64: implement live patching In-Reply-To: Message-ID: References: <20181001140910.086E768BC7@newverein.lst.de> <20181001141652.5478C68BE1@newverein.lst.de> <20181018125820.iw54zbirq74ulknj@linux-8ccs> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > >> Ad relocations. I checked that everything in struct mod_arch_specific > >> stays after the module is load. Both core and init get SHF_ALLOC set > >> (mod->arch.core.plt->sh_flags in module_frob_arch_sections(). It is > >> important because apply_relocate_add() may use those sections > >> through module_emit_plt_entry() call. > > > > > > Yes, it looks like the needed .plt sections will remain in module > > memory. However, I think I found a slight issue... :/ > > > > In module_frob_arch_sections(), mod->arch.core.plt is set to an offset > > within info->sechdrs: > > > > if (!strcmp(secstrings + sechdrs[i].sh_name, ".plt")) > > mod->arch.core.plt = sechdrs + i; > > > > sechdrs is from info->sechdrs, which is freed at the end of > > load_module() via free_copy(). So although the relevant plt section(s) > > are in module memory, mod->arch.core.plt will point to invalid memory > > after info is freed. In other words, the section (.plt) *is* in memory > > but the section header (struct elf64_shdr) containing section metadata > > like sh_addr, sh_size etc., is not. > > > > Just for my understanding: this only matters for live patching, right? Yes. Live patching can do deferred relocations. When a module is loaded and livepatched, the relevant symbols in the patching module are resolved. We call apply_relocate_add(), which is arch-specific, and we must be sure that everything used by apply_relocate_add() is preserved in the patching module after it is loaded. > The original PLT support was implemented to support loading modules > outside of the -/+ 128 MB range of an arm64 relative branch/jump > instruction, and was later enhanced [for the same reason] to support > emitting a trampoline for the ftrace entrypoint. Regards, Miroslav