Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp730617ybz; Sat, 25 Apr 2020 03:05:19 -0700 (PDT) X-Google-Smtp-Source: APiQypJzYkc/Scu0h78W8gBwfUju+7BuTgeKw2ZBez8me1e//eDKiSqoE2r0nREjyuRFiYvunphP X-Received: by 2002:a05:6402:1adc:: with SMTP id ba28mr11319194edb.336.1587809119827; Sat, 25 Apr 2020 03:05:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587809119; cv=none; d=google.com; s=arc-20160816; b=tkUKURxBVE6i3E2D3B26g1s4N1iqZzdUGUOsO08oLuMIevTHGq+DoDIyKushOEWp2b pS3myOPMB4eHmckpWCFaP8BzIATtayM6187m5E6w+1AO+Ni8pZNba0qbaCHcXnTouEkS z+e2+6FHhF6gGmbsYouyH60P32GmP4Bvb9kQBxfgdmuS8Z2EJI5dXihciR18B25f9Gxv fqVzhhXDeXgSgoGfzD2zesVZAfijW/mW+qC74IwIepIRGbZwPBmzUmQ/MpIOuVoTcSii Jo+nLIsL1DGEUkEMb5dYNJwiM3kKS+eSsAZXkt0F2QRNaeGy5nHNYCLEPxtBLdlqUIRm exVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HTQeurswtsRMklK9POrTxGp038FliTq+3jZmxbn4W4I=; b=f8hqcWArxIj1Z7RpC/Tki+iDLr/j1sUPMjc6SaqrtkOcIp4T9XEgD44iaIL82WcUgT Xu+V8PoOxjTjD+174MEGq2YvDFATvsSyLarQ4lIumIgbMVz/zrnsjcre+q6mLm3w431F P+XK3GnUTC5/YtkwjwiIFi2gOXeSNIHtYX1Kk2cBtmHKzizNoh/xIxl+Ipm7QD/4wVjp 28GsTTaLoKQbfgckwMCYtfpOEfDrD2IOTTPKsokCfU5/+0OPFe4bUXx6MVxcpHruqkPH +bUcfh+mNBfU+OKwmF85/C03pdO4fUmRkBoZv2UQ6yh+FFily3upBoFjKzXVTwrzaq6U fNEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=J0u14YLt; 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 sd16si4843272ejb.106.2020.04.25.03.04.56; Sat, 25 Apr 2020 03:05:19 -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=J0u14YLt; 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 S1726125AbgDYKDe (ORCPT + 99 others); Sat, 25 Apr 2020 06:03:34 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:26090 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726076AbgDYKD3 (ORCPT ); Sat, 25 Apr 2020 06:03:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587809007; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HTQeurswtsRMklK9POrTxGp038FliTq+3jZmxbn4W4I=; b=J0u14YLt6KIynHn5qogEWFXSzHMX93vz1wLuA5ocF/r6sDGfsYcVwTcSGYLAp/7iCr6lPs QRNcmm7rgIMrXWPmtJMeCHNHF/eR42JU/yat4xtXYiUlLVazHLwtceWkq5rglio6LV9/cH 9nEG1PDqz1rlZOWZDOueuTQC/f0rfIo= 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-114-UbYHQmPpO-iYF2_WK1QRbg-1; Sat, 25 Apr 2020 06:03:25 -0400 X-MC-Unique: UbYHQmPpO-iYF2_WK1QRbg-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 233CF107ACCA; Sat, 25 Apr 2020 10:03:24 +0000 (UTC) Received: from treble.redhat.com (ovpn-114-29.rdu2.redhat.com [10.10.114.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id A54E46061E; Sat, 25 Apr 2020 10:03:22 +0000 (UTC) From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Vince Weaver , Dave Jones , Jann Horn , Miroslav Benes , Andy Lutomirski , Thomas Gleixner , "Dr. David Alan Gilbert" , Joe Mario , Linus Torvalds Subject: [PATCH v2 03/11] x86/entry/64: Fix unwind hints in kernel exit path Date: Sat, 25 Apr 2020 05:03:02 -0500 Message-Id: <60ea8f562987ed2d9ace2977502fe481c0d7c9a0.1587808742.git.jpoimboe@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In swapgs_restore_regs_and_return_to_usermode, after the stack is switched to the trampoline stack, the existing UNWIND_HINT_REGS hint is no longer valid, which can result in the following ORC unwinder warning: WARNING: can't dereference registers at 000000003aeb0cdd for ip swapgs_= restore_regs_and_return_to_usermode+0x93/0xa0 For full correctness, we could try to add complicated unwind hints so the unwinder could continue to find the registers, but when when it's this close to kernel exit, unwind hints aren't really needed anymore and it's fine to just use an empty hint which tells the unwinder to stop. For consistency, also move the UNWIND_HINT_EMPTY in entry_SYSCALL_64_after_hwframe to a similar location. Fixes: 3e3b9293d392 ("x86/entry/64: Return to userspace from the trampoli= ne stack") Reported-by: Vince Weaver Reported-by: Dave Jones Reported-by: "Dr. David Alan Gilbert" Reported-by: Joe Mario Reported-by: Jann Horn Reported-by: Linus Torvalds Signed-off-by: Josh Poimboeuf Reviewed-by: Miroslav Benes --- arch/x86/entry/entry_64.S | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S index 0e9504fabe52..6b0d679efd6b 100644 --- a/arch/x86/entry/entry_64.S +++ b/arch/x86/entry/entry_64.S @@ -249,7 +249,6 @@ SYM_INNER_LABEL(entry_SYSCALL_64_after_hwframe, SYM_L= _GLOBAL) */ syscall_return_via_sysret: /* rcx and r11 are already restored (see code above) */ - UNWIND_HINT_EMPTY POP_REGS pop_rdi=3D0 skip_r11rcx=3D1 =20 /* @@ -258,6 +257,7 @@ syscall_return_via_sysret: */ movq %rsp, %rdi movq PER_CPU_VAR(cpu_tss_rw + TSS_sp0), %rsp + UNWIND_HINT_EMPTY =20 pushq RSP-RDI(%rdi) /* RSP */ pushq (%rdi) /* RDI */ @@ -637,6 +637,7 @@ SYM_INNER_LABEL(swapgs_restore_regs_and_return_to_use= rmode, SYM_L_GLOBAL) */ movq %rsp, %rdi movq PER_CPU_VAR(cpu_tss_rw + TSS_sp0), %rsp + UNWIND_HINT_EMPTY =20 /* Copy the IRET frame to the trampoline stack. */ pushq 6*8(%rdi) /* SS */ --=20 2.21.1