Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4713308yba; Wed, 8 May 2019 01:14:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxkSCkKyjZeT+mSECi+CzwWdS/BLlLupc6nT2F6NkBTkBLEk8neBqSxBb7PmBZRDNQch90q X-Received: by 2002:a63:6849:: with SMTP id d70mr44196216pgc.21.1557303242430; Wed, 08 May 2019 01:14:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557303242; cv=none; d=google.com; s=arc-20160816; b=KfTetfsT9iOyj7yugDkBYcFEK9F+1H8Oh99E3RNlBqeHc+kWz4+bXKzwbew7wMmD+J /lq4Gf+TOTrBzrchpAmDkpEC3w4dNUONHcnbzA0tcvGxGU1SlG/G4eE40py1XEsuWKWo VSp5G+Ylhke230ChSfzI4vCsj54XLPKOjjUr96q/8NAYeCVZ3E6raJy/MdfMggU12EKo o3XgmmXuchFcnEpTiRbVoCBgB3RxcOaAkovr97SkbqNGy9IBgivRSDJ3ToIUCLCiGtYS 7izLfGnD7sEjuLmcl190vMZvQMvB8NBw+jT5/eWjOleib4Mn/wtIUxFEx2V9WvuFhNAg TpQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:subject:cc:to :from:date:user-agent:message-id:dkim-signature; bh=dH7jDipyW2/IbT3T+4Br1AsjxNtqsrnnxXKC+NJUiRQ=; b=oszf3nzKP8JoxlkuZNErFU8+TTle+jbzfq+fuvuQD3YBTCx3MZEvFQrvxKfms9cfVu xcRRs94KQJrPvbIupxZj2DByPbV7M9w2rLCMSiNu8ooe4fPt876K/DZ/jtZqdmxmLJuR HkOii6Hkz/oUpizL3cxbxlj95q9kl1NEy7jsPJJiLCrGBESudZMj4QVvsgVkmz1kXrlm 9QI2gx5Jymhkrd5QQpc6UcSLR7n4hmavFwx5J4VkiTcqsXwVa5JNEiY9DZwEG93dgO7b Ye8k51Sfuu/BIE4yy/398V5Npjdi8U4wHQeTaOfVV8ecyu7Df4QSUzKZNB5PiEEc5X8s mbuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=fjjDRnMk; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x2si11221947pln.355.2019.05.08.01.13.45; Wed, 08 May 2019 01:14:02 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=fjjDRnMk; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726865AbfEHIMa (ORCPT + 99 others); Wed, 8 May 2019 04:12:30 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:44242 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725891AbfEHIMa (ORCPT ); Wed, 8 May 2019 04:12:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-Id:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=dH7jDipyW2/IbT3T+4Br1AsjxNtqsrnnxXKC+NJUiRQ=; b=fjjDRnMkcQRy/bSUsLCt6Ym7yK 1hmF4nCFE7d0aIWZH3ieSyJOFK25ztJ3uXxJJKTKPR/1E0b6SkEWdz9/j7grE4D6Be5tjlqZ2e4HS p0Mw9Vj84H2NlOSFsWk6ZRYkFUjQiqrBpS9X2KQIOIbAtAyCL1urRXNYZ1mL8mlFj0LgiFNlyvP3f NrhCjQmyOizKgr9LYKePNGdg7eykF1nJw6EZPzQt7z0l2w8RbUXaU0lyDAwGpamuHgEInI8odH7ex OqA75UmlhaxJEKFqBXpF+Q5aiGWB0i04q6F9+JK6LQWqEx85jO1bwWQabnvPwHsXQD3R5x/YacSmr 1HjhRaTA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hOHgM-00012a-TP; Wed, 08 May 2019 08:12:07 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 2D5072029F87E; Wed, 8 May 2019 10:12:05 +0200 (CEST) Message-Id: <20190508080612.721269814@infradead.org> User-Agent: quilt/0.65 Date: Wed, 08 May 2019 09:49:03 +0200 From: Peter Zijlstra To: linux-kernel@vger.kernel.org Cc: Linus Torvalds , Peter Zijlstra , Ingo Molnar , Andrew Morton , Andy Lutomirski , Nicolai Stange , Thomas Gleixner , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, Josh Poimboeuf , Jiri Kosina , Miroslav Benes , Petr Mladek , Joe Lawrence , Shuah Khan , Konrad Rzeszutek Wilk , Tim Chen , Sebastian Andrzej Siewior , Mimi Zohar , Juergen Gross , Nick Desaulniers , Nayna Jain , Masahiro Yamada , Joerg Roedel , linux-kselftest@vger.kernel.org, Masami Hiramatsu Subject: [PATCH 2/4] x86/kprobes: Fix frame pointer annotations References: <20190508074901.982470324@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The kprobe trampolines have a FRAME_POINTER annotation that makes no sense. It marks the frame in the middle of pt_regs, at the place of saving BP. Change it to mark the pt_regs frame as per the ENCODE_FRAME_POINTER from the respective entry_*.S. Signed-off-by: Peter Zijlstra (Intel) --- arch/x86/kernel/kprobes/common.h | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) --- a/arch/x86/kernel/kprobes/common.h +++ b/arch/x86/kernel/kprobes/common.h @@ -6,14 +6,15 @@ #include +#ifdef CONFIG_X86_64 + #ifdef CONFIG_FRAME_POINTER -# define SAVE_RBP_STRING " push %" _ASM_BP "\n" \ - " mov %" _ASM_SP ", %" _ASM_BP "\n" +#define ENCODE_FRAME_POINTER \ + " leaq 1(%rsp), %rbp\n" #else -# define SAVE_RBP_STRING " push %" _ASM_BP "\n" +#define ENCODE_FRAME_POINTER #endif -#ifdef CONFIG_X86_64 #define SAVE_REGS_STRING \ /* Skip cs, ip, orig_ax. */ \ " subq $24, %rsp\n" \ @@ -27,11 +28,13 @@ " pushq %r10\n" \ " pushq %r11\n" \ " pushq %rbx\n" \ - SAVE_RBP_STRING \ + " pushq %rbp\n" \ " pushq %r12\n" \ " pushq %r13\n" \ " pushq %r14\n" \ - " pushq %r15\n" + " pushq %r15\n" \ + ENCODE_FRAME_POINTER + #define RESTORE_REGS_STRING \ " popq %r15\n" \ " popq %r14\n" \ @@ -51,19 +54,30 @@ /* Skip orig_ax, ip, cs */ \ " addq $24, %rsp\n" #else + +#ifdef CONFIG_FRAME_POINTER +#define ENCODE_FRAME_POINTER \ + " movl %esp, %ebp\n" \ + " andl $0x7fffffff, %ebp\n" +#else +#define ENCODE_FRAME_POINTER +#endif + #define SAVE_REGS_STRING \ /* Skip cs, ip, orig_ax and gs. */ \ - " subl $16, %esp\n" \ + " subl $4*4, %esp\n" \ " pushl %fs\n" \ " pushl %es\n" \ " pushl %ds\n" \ " pushl %eax\n" \ - SAVE_RBP_STRING \ + " pushl %ebp\n" \ " pushl %edi\n" \ " pushl %esi\n" \ " pushl %edx\n" \ " pushl %ecx\n" \ - " pushl %ebx\n" + " pushl %ebx\n" \ + ENCODE_FRAME_POINTER + #define RESTORE_REGS_STRING \ " popl %ebx\n" \ " popl %ecx\n" \