Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp7803837yba; Thu, 2 May 2019 17:01:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqxXfx4tuwEEKDzB7QPqxgEfYjjgBVit0QLRveb6sH6dV5JgVsjklz3vRRrYwKJxjw7X5EnV X-Received: by 2002:a17:902:9a83:: with SMTP id w3mr6823392plp.241.1556841660134; Thu, 02 May 2019 17:01:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556841660; cv=none; d=google.com; s=arc-20160816; b=amm/FL1FcrfgbtXhNxNJE6MdUPtOMjmSRsp426bG1BroyuhfVqiftHePJUdYBjPbvI mcud3y1JOrJ7x5eDiMjK0aDib3reGSST4/6qyN+jANDI+DhtlgNxQY8ggHI2Q2G/X6+f 6YAXLOptn4SXbw3WMXjO7SeWva6sK9M8nioyngOF6Jz+hSZRH3Gripi+OCpdvEPTQgSs wyNg4x44fJ6ZyxkhssXD6s+Q6v83l42azBLbwGltOs5eAd4oVqvmCKbBcc9WLFG5cv6N ayLRgH6UvYWoqHN1uV2yu+HUcCY31jFJvE+jw/soyVovdTbdctNYTrEOuoFTmgvBBL8u rKaw== 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:subject:cc:to:from:date; bh=vtOFRLorpoJ1JPtfyI1/BcN9xQYS8f9qZKSFO2Ab4KQ=; b=J2+xsUKYKbkEWw17AYmPyF6l1A+RMdgzFSVX8GCcPnTCmD1eU2AA703sHGsTWIPBxq nz7LEzSZnTKSimINI2ELutLwPoWfGc+tb+BracuYGOYo7JySUM9QIsblXaJgn5Y7gpJJ yRsp0Fd9b47pW9esrD42BG357kA5bhWg/Xta8J+3N0HMf0NrgI7kJTzCV8Sxf8pFx15q 2cB2E1ZeSbRVIDm5X+K58wBPd2BalayRerxXyytEw70wQkEUW4P0uAksp1GetJ5C3WmR egtSY6RYiqlFWyKat2olyUC3XMe9Enzsj7Gt70GRcA12vF1TYAN117+mPyhGDcAAIC61 l5bg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e25si454413pfi.123.2019.05.02.17.00.44; Thu, 02 May 2019 17:01:00 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726406AbfEBXu5 (ORCPT + 99 others); Thu, 2 May 2019 19:50:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:38416 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726053AbfEBXu5 (ORCPT ); Thu, 2 May 2019 19:50:57 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 179E82085A; Thu, 2 May 2019 23:50:54 +0000 (UTC) Date: Thu, 2 May 2019 19:50:52 -0400 From: Steven Rostedt To: Peter Zijlstra Cc: Linus Torvalds , Linux List Kernel Mailing , Ingo Molnar , Andrew Morton , Andy Lutomirski , Nicolai Stange , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , the arch/x86 maintainers , 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 , "open list:KERNEL SELFTEST FRAMEWORK" , stable Subject: Re: [RFC][PATCH 1/2] x86: Allow breakpoints to emulate call functions Message-ID: <20190502195052.0af473cf@gandalf.local.home> In-Reply-To: <20190502193129.664c5b2e@gandalf.local.home> References: <20190501202830.347656894@goodmis.org> <20190501203152.397154664@goodmis.org> <20190501232412.1196ef18@oasis.local.home> <20190502162133.GX2623@hirez.programming.kicks-ass.net> <20190502181811.GY2623@hirez.programming.kicks-ass.net> <20190502202146.GZ2623@hirez.programming.kicks-ass.net> <20190502185225.0cdfc8bc@gandalf.local.home> <20190502193129.664c5b2e@gandalf.local.home> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2 May 2019 19:31:29 -0400 Steven Rostedt wrote: > Digging a little further, I pinpointed it out to being kretprobes. The > problem I believe is the use of kernel_stack_pointer() which does some > magic on x86_32. kretprobes uses this to hijack the return address of > the function (much like the function graph tracer does). I do have code > that would allow kretprobes to use the function graph tracer instead, > but that's still in progress (almost done!). But still, we should not > have this break the use of kernel_stack_pointer() either. > > Adding some printks in that code, it looks to be returning "®s->sp" > which I think we changed. > This appears to fix it! -- Steve diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c index 4b8ee05dd6ad..600ead178bf4 100644 --- a/arch/x86/kernel/ptrace.c +++ b/arch/x86/kernel/ptrace.c @@ -171,8 +171,12 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs) unsigned long sp = (unsigned long)®s->sp; u32 *prev_esp; - if (context == (sp & ~(THREAD_SIZE - 1))) + if (context == (sp & ~(THREAD_SIZE - 1))) { + /* int3 code adds a gap */ + if (sp == regs->sp - 5*4) + return regs->sp; return sp; + } prev_esp = (u32 *)(context); if (*prev_esp)