From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752750AbcBZKh6 (ORCPT ); Fri, 26 Feb 2016 05:37:58 -0500 Received: from ozlabs.org ([103.22.144.67]:53671 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751505AbcBZKhz (ORCPT ); Fri, 26 Feb 2016 05:37:55 -0500 Message-ID: <1456483072.25691.11.camel@ellerman.id.au> Subject: Re: [PATCH 02/12] powerpc/module: Mark module stubs with a magic value From: Michael Ellerman To: Torsten Duwe Cc: linuxppc-dev@ozlabs.org, bsingharora@gmail.com, linux-kernel@vger.kernel.org, rostedt@goodmis.org, kamalesh@linux.vnet.ibm.com, pmladek@suse.com, jeyu@redhat.com, jkosina@suse.cz, live-patching@vger.kernel.org, mbenes@suse.cz Date: Fri, 26 Feb 2016 21:37:52 +1100 In-Reply-To: <20160225131727.GD21932@lst.de> References: <1456324115-21144-1-git-send-email-mpe@ellerman.id.au> <1456324115-21144-2-git-send-email-mpe@ellerman.id.au> <20160225131727.GD21932@lst.de> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.16.5-1ubuntu3.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2016-02-25 at 14:17 +0100, Torsten Duwe wrote: > On Thu, Feb 25, 2016 at 01:28:25AM +1100, Michael Ellerman wrote: > > > > We can make that process easier by marking the generated stubs with a > > magic value, and then looking for that magic value. Altough this is not > > as rigorous as the current method, I believe it is sufficient in > > practice. > > The actual magic value is sort of debatable; it should be "improbable" > enough. But this can be changed easily, for each kernel compile, even. Yeah. Given the locations we're trying to patch are computed in the first place from the mcount call sites, I feel like we don't need to be super paranoid here. The only time I've heard of this code (the current version) tripping up is when folks are hacking on ftrace. > > Signed-off-by: Michael Ellerman > Reviewed-by: Torsten Duwe > > [for reference:] > > +#define STUB_MAGIC 0x73747562 /* stub */ Which is one of: ori r21,r19,29811 andi. r20,r27,30050 Both of which are pretty improbable. They don't appear in any kernel I have around here. I have more plans for this code, which would hopefully mean we can get rid of the magic checking entirely. But I think this is OK for now. cheers