Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6875075imu; Wed, 14 Nov 2018 08:14:30 -0800 (PST) X-Google-Smtp-Source: AJdET5f/JWFumXSRjKylEo6bMo3pF+U6RjVcrba68CAQ+wUa2aSfPTu/FSucP9o457qwimQYxD01 X-Received: by 2002:a62:4b4b:: with SMTP id y72-v6mr2589397pfa.67.1542212070020; Wed, 14 Nov 2018 08:14:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542212069; cv=none; d=google.com; s=arc-20160816; b=SZxasAYg7uNssHKvU5nZKnbwwXm++W39pp4MHlFWS/uYpu1CBX/Dk9eFoNBwLQ/CCs Xs5kb/kQH394XDvnk3JxqUSC1QYLVOYUeOq1SC+tlHdALXPOXvRqBcRWwwzAhEv2TLAZ cvc4p+AqCBXk54v4Aey2CBfcb4/XQdNYpHdrmZjPmnAaupf3dQL2hWtS78zwXbiLA7FG pN9Ks4bO+dILKTfP8X//07FYpj07QEPZhurzZ3DfbJqaVVY+9I69jvv9Lpu3Mamd3epr UMNDSIH0xCDcigfH24Re2kq2CCnogK21TfA5t8U3taF/WUcw7wPvqQ0jYw2uwWnEGNZA 4XTg== 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:dkim-signature; bh=JrQVG8+FLDgX/49xodzBqDHYinx5YOw26+nO/U7ULjA=; b=Ch7qDqGmCvxvVrTgFT5EnU0bSOulU1CZRLOdiT3KCZ/piVdTM9aISttOyJJ3eVq7YS xmTU7R6MFBxRf0Syxdn24eKOaKG0GKVKXrAEPHz5OjV7e9cL1os+NNdHxP/8N94qqM6q xALx99lHWIxdAWimMlGwgKxFKTNO+cxKZbYjRehLsJSoCvzdIRUsBxcieD9tSW7O2KOX MdPmYYF+Dnltcuu9SxdjADgfLwJV+65DNvhZGPhni3vMBUs46APQq8gY+R1a77l3dif9 DVKbzbylreymc0rNwv5qbZoaiQdR1Lf2mZSoH7zvkSXNrxjmuNynXQMBIqhHA9zc9tJ8 veAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NFga16Q2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d10si9661196pls.170.2018.11.14.08.14.09; Wed, 14 Nov 2018 08:14:29 -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; dkim=pass header.i=@kernel.org header.s=default header.b=NFga16Q2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733191AbeKOCO4 (ORCPT + 99 others); Wed, 14 Nov 2018 21:14:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:34610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726295AbeKOCO4 (ORCPT ); Wed, 14 Nov 2018 21:14:56 -0500 Received: from linux-8ccs (ip5f5adbda.dynamic.kabel-deutschland.de [95.90.219.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 398B022360; Wed, 14 Nov 2018 16:11:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542211864; bh=3FCN5veeezIRtQ+R8Sag7FMmSBB1PQgfbmBuHFamN6s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NFga16Q2G+FT9lcgA7G9DERYQR0J1QKduBVxLw/7kcbE2tCxwGnJG+WrvY6uH+YAy l30PNvZ40STfBJq6glAYf4Fc9q/43Dge6D37lw8BNY+mZwag5baG1stywXUFauHBsp NdGcDS9S4qEv+ve9lMzk7YSgqY5S/KqjgUiClgnU= Date: Wed, 14 Nov 2018 17:10:59 +0100 From: Jessica Yu To: Vincent Whitchurch 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: <20181114161059.GB13928@linux-8ccs> References: <20181031084253.9650-1-vincent.whitchurch@axis.com> <20181031155341.GA27878@linux-8ccs> <20181101152913.r2isskngiahi6o2u@axis.com> <20181102135322.GA5289@linux-8ccs> <20181109135300.3tyord6amvd7wy54@axis.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20181109135300.3tyord6amvd7wy54@axis.com> X-OS: Linux linux-8ccs 4.12.14-lp150.12.22-default x86_64 User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +++ Vincent Whitchurch [09/11/18 14:53 +0100]: >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. D'oh, I just contradicted myself. Yes, you are correct. AFAIK the only reason we haven't run into issues yet in livepatch is because the only arches it currently supports (x86, s390, powerpc) don't depend on st_info for module relocations. But yes, that's an outstanding problem that will need to be fixed if livepatch gains support on more arches, we shouldn't be overwriting that field. And after grepping around I do see that st_other is used in powerpc, alpha, sh for module relocations. I suggested in my other reply to your v3 patch that reusing st_size instead of st_info might work, since it's not used in the module loader/kallsyms, and arches don't seem to use it for module relocs. Maybe that would work? Jessica