Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4528009ybz; Tue, 28 Apr 2020 13:00:20 -0700 (PDT) X-Google-Smtp-Source: APiQypIYESOk5I5jBfiGt3W4JGR0vIfNljEyVEIV6djXJYW0kSiMUHD5x5VVTP0hM48kSFqngU9v X-Received: by 2002:a50:a685:: with SMTP id e5mr22660041edc.243.1588104020806; Tue, 28 Apr 2020 13:00:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588104020; cv=none; d=google.com; s=arc-20160816; b=j/GtxztbYkWLm76PQvn4+wlFWJmQsZumdzkL+WJ4Yyrb/fkYDKStbKELhAlLU3KcqG sAeYnAitSTrRashtQjOU1VIgRqplFhrzu9j5nwyFeUhKCumWrFJMfcQ7RQWrQuH/e2+W PzS9LsuaDusBYcw+wQPoCSu93zQLQscmUWdpTcq+aYJj0Y/F+Zs0Hi9SUUZAB10UQRmW zNi3rYdst9TTu95pGESQuIJMvOJazKzUQTlA3pH7CZiTwANtQbind4q/k1ZHOTGLAgny hq4tpSdQQ8Mi8HuZLS82Hr1Zk4qbjdPZY/cWT6Xgp3vfUmVNPv1P4AEY4etmpo+zXMYW +y1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=wnxZ+MGYIfVpjNWWL77weyCkpT6dVXtZj0ovH4iODX0=; b=nZOLZmG5i+7pxPi1Iq8/bcy4hMVyqyHCp15dh68q6bP+rWoxeud15fKB0XrGYfZ5If rMN46/sR6deosr+nuEwAXYbEyJoSp2wfeLz3H2KH5adyT5gd9Hfv7f3dWnB+20KeyFtz fnRMiS6yVCQ6hQ4ET708cSiRjubuQx4njYdQXOe95YLRyJmhmDiVSnUEX05xvpiMnABC 5RIRKm00FVvZQ0WBDBKn+mqGPZNPRpnIPW4rTi6OetBq62zMWmnLEmAfxfWJnkxf8Hi1 hq6hmq6/by5eqyueTQLN5g+o1L0iUoBRy1NTgwGdTHZPfxEfn6RNPy8byt4mUdYRxDxA kn+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZHBKioGq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dr18si939672ejc.34.2020.04.28.12.59.56; Tue, 28 Apr 2020 13:00:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZHBKioGq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728991AbgD1Tzd (ORCPT + 99 others); Tue, 28 Apr 2020 15:55:33 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:32375 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728713AbgD1Tzd (ORCPT ); Tue, 28 Apr 2020 15:55:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588103732; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=wnxZ+MGYIfVpjNWWL77weyCkpT6dVXtZj0ovH4iODX0=; b=ZHBKioGqC5fOCm5B1qPXXuR3/rNRn5UkalmvK5gxaOizZYUluRG+NyWiYzAJH8F5cdYbEr cZYmv6un7wO5bcJTQTMh/1VT/uBQxKyb7E6Z+6vscRMOc7tq4SfSY2j67N2kqKjpJPv+w/ Us0Z812GAm4EzxK91HfrsOoPuWJ1Je8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-79-sRF5gptWPbqB8tamEeScuw-1; Tue, 28 Apr 2020 15:55:28 -0400 X-MC-Unique: sRF5gptWPbqB8tamEeScuw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 37B41187661D; Tue, 28 Apr 2020 19:55:27 +0000 (UTC) Received: from treble (ovpn-112-209.rdu2.redhat.com [10.10.112.209]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0B45A60638; Tue, 28 Apr 2020 19:55:25 +0000 (UTC) Date: Tue, 28 Apr 2020 14:55:24 -0500 From: Josh Poimboeuf To: Peter Zijlstra Cc: alexandre.chartre@oracle.com, linux-kernel@vger.kernel.org, jthierry@redhat.com, tglx@linutronix.de, x86@kernel.org, mbenes@suse.cz, Jann Horn Subject: Re: [PATCH v2 02/14] objtool: Fix ORC vs alternatives Message-ID: <20200428195524.iidaw7vjrnyrq72l@treble> References: <20200428191101.886208539@infradead.org> <20200428191659.499074346@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200428191659.499074346@infradead.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 28, 2020 at 09:11:03PM +0200, Peter Zijlstra wrote: > Jann reported that (for instance) entry_64.o:general_protection has > very odd ORC data: > > 0000000000000f40 : > #######sp:sp+8 bp:(und) type:iret end:0 > f40: 90 nop > #######sp:(und) bp:(und) type:call end:0 > f41: 90 nop > f42: 90 nop > #######sp:sp+8 bp:(und) type:iret end:0 > f43: e8 a8 01 00 00 callq 10f0 > #######sp:sp+0 bp:(und) type:regs end:0 > f48: f6 84 24 88 00 00 00 testb $0x3,0x88(%rsp) > f4f: 03 > f50: 74 00 je f52 > f52: 48 89 e7 mov %rsp,%rdi > f55: 48 8b 74 24 78 mov 0x78(%rsp),%rsi > f5a: 48 c7 44 24 78 ff ff movq $0xffffffffffffffff,0x78(%rsp) > f61: ff ff > f63: e8 00 00 00 00 callq f68 > f68: e9 73 02 00 00 jmpq 11e0 > #######sp:(und) bp:(und) type:call end:0 > f6d: 0f 1f 00 nopl (%rax) > > Note the entry at 0xf41. Josh found this was the result of commit: > > 764eef4b109a ("objtool: Rewrite alt->skip_orig") > > Due to the early return in validate_branch() we no longer set > insn->cfi of the original instruction stream (the NOPs at 0xf41 and > 0xf42) and we'll end up with the above weirdness. > > In other discussions we realized alternatives should be ORC invariant; > that is, due to there being only a single ORC table, it must be valid > for all alternatives. The easiest way to ensure this is to not allow > any stack modifications in alternatives. > > When we enforce this latter observation, we get the property that the > whole alternative must have the same CFI, which we can employ to fix > the former report. > > Fixes: 764eef4b109a ("objtool: Rewrite alt->skip_orig") > Reported-by: Jann Horn > Signed-off-by: Peter Zijlstra (Intel) > --- > tools/objtool/Documentation/stack-validation.txt | 7 ++++ > tools/objtool/check.c | 34 ++++++++++++++++++++++- > 2 files changed, 40 insertions(+), 1 deletion(-) > > --- a/tools/objtool/Documentation/stack-validation.txt > +++ b/tools/objtool/Documentation/stack-validation.txt > @@ -315,6 +315,13 @@ they mean, and suggestions for how to fi > function tracing inserts additional calls, which is not obvious from the > sources). > > +10. file.o: warning: func()+0x5c: alternative modifies stack > + > + This means that an alternative includes instructions that modify the > + stack. The problem is that there is only one ORC unwind table, this means > + that the ORC unwind entries must be valid for each of the alternatives. > + The easiest way to enforce this is to ensure alternative do not contain "alternatives" Acked-by: Josh Poimboeuf -- Josh