Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp770596imu; Fri, 9 Nov 2018 05:56:06 -0800 (PST) X-Google-Smtp-Source: AJdET5e1M5feZ7Wzn2tl76F3B4mjjshd9+/OaVvitRQOVWEXZHsEEMJEG4sF3suUPtfMDr4pJXrZ X-Received: by 2002:a62:7f8c:: with SMTP id a134-v6mr9333660pfd.22.1541771766739; Fri, 09 Nov 2018 05:56:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541771766; cv=none; d=google.com; s=arc-20160816; b=a1T5rr4hCmDO4F6mxvtIy4p1pCH032khbKSyiHO/lhHMQG3RtklTb1HIxtxhfhAVud ABoQILlkus8v3atFp41DlKX5K2K/pgR4B0oLNgVqvESpzwH6+jWTMTLvqaN/0cXMTVF7 +cgrS0UWiZhPLFyZojpFswfNP2TsYaYjx/xG1bRcFOI4r4HmzhM8WdRpq7oNXXpTO7oS a9XR6RUqoBxRwUrQccrzSmC9QT9Dkly3Rx6qBFPa5YpbQ0OrfENlCRIDuU6YxpHwCVqy JUf3AREJjy/AG/oWouKZhfpFJsMPsG563ACgNdY1RaH7/k0WQhiKoDV9hBcige4VuXs6 RMKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=/VuZ+Ceyda4nYvSpOoKKN4972AmF/5+ErwZBNYXJyDU=; b=cb2GBfHVFiWm1NGjSeI4KKQRDg7M91g5aTVxf/6NDBNqaXghqAFLLzdMfZedFMnNLW S4HTvNgvvhXPphcsasVdOD7BrFarlFHRgZCKpYPfc+/Finnx2atwHigCPiAxUGbNP4+G tHEQbhgkRNBtm4/2OFGc49ANX0874BazYSOHdnoi12tpAp+f9qpmUpgoJQLm8SY/O/Ai iUUTJuMKU9kwdb+QwkpibPk3HKFM7Md98ondvbhULqPhYACLHpNHnYszPAcvyRSzqPYW pT36/wUD5UpKDPr0H19AYDZWL5+egO+PqvgcNVK4Siyv0tqAyPFnhG6au3ujBlT2AUHY dXuQ== 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 y16-v6si5983450pgk.479.2018.11.09.05.55.44; Fri, 09 Nov 2018 05:56:06 -0800 (PST) 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 S1728134AbeKIXds (ORCPT + 99 others); Fri, 9 Nov 2018 18:33:48 -0500 Received: from bastet.se.axis.com ([195.60.68.11]:59531 "EHLO bastet.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727735AbeKIXds (ORCPT ); Fri, 9 Nov 2018 18:33:48 -0500 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id 2EBFD185B0; Fri, 9 Nov 2018 14:53:02 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bastet.se.axis.com Received: from bastet.se.axis.com ([IPv6:::ffff:127.0.0.1]) by localhost (bastet.se.axis.com [::ffff:127.0.0.1]) (amavisd-new, port 10024) with LMTP id S1q5t2goXaH4; Fri, 9 Nov 2018 14:53:01 +0100 (CET) Received: from boulder03.se.axis.com (boulder03.se.axis.com [10.0.8.17]) by bastet.se.axis.com (Postfix) with ESMTPS id 59D001818A; Fri, 9 Nov 2018 14:53:01 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3A7331E07D; Fri, 9 Nov 2018 14:53:01 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2E5881E07C; Fri, 9 Nov 2018 14:53:01 +0100 (CET) Received: from thoth.se.axis.com (unknown [10.0.2.173]) by boulder03.se.axis.com (Postfix) with ESMTP; Fri, 9 Nov 2018 14:53:01 +0100 (CET) Received: from lnxartpec.se.axis.com (lnxartpec.se.axis.com [10.88.4.9]) by thoth.se.axis.com (Postfix) with ESMTP id 211E92EA5; Fri, 9 Nov 2018 14:53:01 +0100 (CET) Received: by lnxartpec.se.axis.com (Postfix, from userid 10564) id 1CCA580C23; Fri, 9 Nov 2018 14:53:01 +0100 (CET) Date: Fri, 9 Nov 2018 14:53:01 +0100 From: Vincent Whitchurch To: Jessica Yu Cc: linux@armlinux.org.uk, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, live-patching@vger.kernel.org Subject: Re: [PATCH v2] ARM: module: Fix function kallsyms on Thumb-2 Message-ID: <20181109135300.3tyord6amvd7wy54@axis.com> References: <20181031084253.9650-1-vincent.whitchurch@axis.com> <20181031155341.GA27878@linux-8ccs> <20181101152913.r2isskngiahi6o2u@axis.com> <20181102135322.GA5289@linux-8ccs> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181102135322.GA5289@linux-8ccs> User-Agent: NeoMutt/20170113 (1.7.2) X-TM-AS-GCONF: 00 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 02, 2018 at 02:53:22PM +0100, Jessica Yu wrote: > +++ Vincent Whitchurch [01/11/18 16:29 +0100]: > > On Wed, Oct 31, 2018 at 04:53:41PM +0100, Jessica Yu wrote: > > > Could this be done in modpost? I'm guessing the answer is no as some > > > relocations may rely on that bit being set in st_value, right? > > > Therefore we can only clear the bit _after_ relocations to the module > > > are applied at runtime, correct? > > > > Yes, that's correct, it needs to be done after the relocations. > > > > > I'm not against having an arch-specific kallsyms fixup function, my > > > only concern would be if this would interfere with the delayed > > > relocations livepatching does, if there are plans in the future to > > > have livepatching on arm (IIRC there was an attempt at a port in > > > 2016). If there exists some Thumb-2 relocation types that rely on that > > > lowest bit in st_value being set in order to be applied, and we clear > > > it permanently from the symtab, then livepatching wouldn't be able to > > > apply those types of relocations anymore. If this is a legitimate > > > concern, then perhaps an alternative solution would be to have an > > > arch-specific kallsyms symbol-value-fixup function for accesses to > > > sym.st_value, without modifying the module symtab. > > > > I'm not familiar with livepatching, but yes, if it needs to do > > relocations later I guess we should preserve the original value. > > Yeah, I think the symtab needs to remain unmodified for livepatch to > be able to do delayed relocations after module load. > > > I gave the alternative solution a go and it seems to work. > > add_kallsyms() currently overwrites st_info so I had to move the > > elf_type to the unused st_other field instead to preserve st_info: > > I think that's fine, I think the only usages of st_other I've found > are during relocations, and the field is big enough for a char, so it > should be fine to reuse it afterwards. If livepatch can do relocations later, doesn't that mean that we _can't_ reuse st_other for storing the elf_type? OTOH, the current code overwrites st_info, and I see that used from various archs' relocation functions too, so perhaps I'm missing something.