Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4291612imm; Mon, 8 Oct 2018 19:17:55 -0700 (PDT) X-Google-Smtp-Source: ACcGV61A5M9w/veBe6umZiDKnHri8Tz+aUrSQWHW/4tkl230tZQOsPko0/jPvObXGco8z0AuKr1h X-Received: by 2002:a62:f553:: with SMTP id n80-v6mr27647683pfh.59.1539051475934; Mon, 08 Oct 2018 19:17:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539051475; cv=none; d=google.com; s=arc-20160816; b=t4g4dEekykClRYQ05JUwjRky68mZTvKXJu0qBsHAeru27zjuKuT2tPK8ThFfCPxTCm sZ7qaMVxVVktE8Btv3M3j3NtkmWwFzfl+E9jrOGWe0N4wef0NITFM3sKWyolqeQanunF KpVQcbNM0iCveO+CgFC4apd3uhDX78vYz34x78bz29+f+a/K/H3cdN8lCPsv38VoI4j7 XUwpKugLW5sWH5bOwfU/Tv4/auIcIjIps5hGs9BR6/jwCuVxNIXzAROh8qJgjnCtiOO1 ZZzZLcuQUSjzvjzoE7mJjya1HHprSarZVXk2YnqxdrynQj8TTeJYsi67cNcFnmlt2saq hIqA== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=z2dGPSVWadS8z4qn1fp4gZtUXWCyKHo+rRVVdt6JK/I=; b=EzKpe9FLGDYwMbGusMwXq4IgfUi/eNyASw/mtId7Wd82M8RWbcodwbBPlxZY1sgI6Q 18RLHroiG28pyHb4xuZI/Bv1A61yDOf1ot6WdJoQ+AlVmdgbHdP9PuQBD8Ul7Rcfi1Dm 4iESaBG+DDLG+FGDo2bjeG7qvtUD6keerJ6USsec4BRY+HsRvOex31h3gAwuaRqF8Ftv Cb5xjbNLDgSGWDhWdCqPLjhE52FNezDthgSH4aa7wJE3TfS33S9UxldmAtMchPKJvTos JE8jwu3K+HkobNARo0L729BomM3KUO0aPc309iHf8A/R2UM7gxK4/X9xDikgpu9zijtl 9jKw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b2-v6si18058668pgw.310.2018.10.08.19.17.38; Mon, 08 Oct 2018 19:17:55 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726665AbeJIJbw (ORCPT + 99 others); Tue, 9 Oct 2018 05:31:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42636 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725887AbeJIJbw (ORCPT ); Tue, 9 Oct 2018 05:31:52 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9F5ECC004AA1; Tue, 9 Oct 2018 02:17:15 +0000 (UTC) Received: from treble (ovpn-120-103.rdu2.redhat.com [10.10.120.103]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9208E26565; Tue, 9 Oct 2018 02:17:12 +0000 (UTC) Date: Mon, 8 Oct 2018 21:17:10 -0500 From: Josh Poimboeuf To: Andy Lutomirski Cc: Peter Zijlstra , Steven Rostedt , linux-kernel@vger.kernel.org, Linus Torvalds , Ingo Molnar , Andrew Morton , Thomas Gleixner , Masami Hiramatsu , Mathieu Desnoyers , Matthew Helsley , "Rafael J . Wysocki" , David Woodhouse , Paolo Bonzini , Jason Baron , Jiri Kosina , ard.biesheuvel@linaro.org, Andy Lutomirski Subject: Re: [POC][RFC][PATCH 1/2] jump_function: Addition of new feature "jump_function" Message-ID: <20181009021710.qwt5hpntyeps44h3@treble> References: <20181006015110.653946300@goodmis.org> <20181006015720.634688468@goodmis.org> <20181006121211.GA5663@hirez.programming.kicks-ass.net> <20181006093905.46276505@vmware.local.home> <20181008072134.GB5663@hirez.programming.kicks-ass.net> <20181008155757.GC5663@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 09 Oct 2018 02:17:16 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 08, 2018 at 09:29:56AM -0700, Andy Lutomirski wrote: > > > > On Oct 8, 2018, at 8:57 AM, Peter Zijlstra wrote: > > > > On Mon, Oct 08, 2018 at 01:33:14AM -0700, Andy Lutomirski wrote: > >>> Can't we hijack the relocation records for these functions before they > >>> get thrown out in the (final) link pass or something? > >> > >> I could be talking out my arse here, but I thought we could do this, > >> too, then changed my mind. The relocation records give us the > >> location of the call or jump operand, but they don’t give the address > >> of the beginning of the instruction. > > > > But that's like 1 byte before the operand, right? We could even double check > > this by reading back that byte and ensuring it is in fact 0xE8 (CALL). > > > > AFAICT there is only the _1_ CALL encoding, and that is the 5 byte: E8 , > > so if we have the PLT32 location, we also have the instruction location. Or am > > I missing something? > > There’s also JMP and Jcc, any of which can be used for rail calls, but > those are also one byte. I suppose GCC is unlikely to emit a prefixed > form of any of these. So maybe we really can assume they’re all one > byte. I'm pretty sure only a basic JMP is used for tail calls. > But there is a nasty potential special case: anything that takes the > function’s address. This includes jump tables, computed gotos, and > plain old function pointers. And I suspect that any of these could > have one of the rather large number of CALL/JMP/Jcc bytes before the > relocation by coincidence. But those special cases aren't in a text section, right? If we just make sure the relocations are applied to a text section, and that they're preceded by the CALL or JMP byte, wouldn't that be sufficient? I'm not really convinced we need objtool for this, maybe I'll try whipping up a POC. -- Josh