Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp803930imd; Sat, 3 Nov 2018 10:34:10 -0700 (PDT) X-Google-Smtp-Source: AJdET5dZBX48QF/YAen5BdxTahKGIQNPX7Eqz5qV0RdPl3YDs9R3lBEr0XbJgc25bPJ0JHvouz71 X-Received: by 2002:a63:f960:: with SMTP id q32-v6mr14326131pgk.213.1541266450779; Sat, 03 Nov 2018 10:34:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541266450; cv=none; d=google.com; s=arc-20160816; b=b72CjRhK7vx57LksPADkuEiHQD1Wcqq6Zolupi6iwoHswnWyGmUyr0BDkbsgwFI7rs cAEH1H/xrcv7ql42/ZsWDUQK+kQ5JPov0mvqpDQx7aSpGZpn+EPMDiFqTwyULglUDBxz eL2T7YdWal5owJ0frHLuDuyY+2wMHt5eLbEzrQQAqKxp5sKFtV/aCfQdyUJiUWmWxFxZ sUMMWvp6MktCpJMoHxzoONdOLLl7zlnnlzbTRs0P5U1AyTH1pL1VNqMsQUIQhsVR2DV1 Xa6kI6WwDU+zko+WoidbLAj+N5SPHhf8XhdWPR6bLwAuLgox5lzEUGbr5mIXwa3dW5z/ vdoA== 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=Q5PBgLZwzri1SG+xeMe3+RYseMNJMSeiT5aa0qqs3q4=; b=iiJogGbOtdAC/ypnRTy1gYNCjwCXkE0YZNuk7leEQhLaDzFrql6YLhQfXH7LxVq0Cb OpBKwgGRhjSC/2nXNpEGiTAnesXf2lHUKDO6Gw0VkpkkpFUMqaRUX9quY8SANnY+olag 2rk8QPxrzWzrjz1W6NxNIIoN+GRwe1rXWcXThKxhIzDun+XSkPtXFlGEJoZjmp6jqmoT O1gUor9BL4fbxSvbCpQ+cK3QEhoYF7kwp/n+JslkXtAuXsgJZXb7zeH8/R7X9ngk17fg fRoQYT++kphNWMX91khH9X6mbt3hWR44JzZ1sRxpC1/RWQE5Gc0ogy5hCZz9oUn4TDQy 9JUA== 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 h71-v6si26665771pgc.122.2018.11.03.10.33.56; Sat, 03 Nov 2018 10:34:10 -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 S1728723AbeKDCp2 (ORCPT + 99 others); Sat, 3 Nov 2018 22:45:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:38310 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726985AbeKDCp2 (ORCPT ); Sat, 3 Nov 2018 22:45:28 -0400 Received: from vmware.local.home (cpe-66-24-56-78.stny.res.rr.com [66.24.56.78]) (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 6896D204FD; Sat, 3 Nov 2018 17:33:31 +0000 (UTC) Date: Sat, 3 Nov 2018 13:33:29 -0400 From: Steven Rostedt To: Masami Hiramatsu Cc: Josh Poimboeuf , Aleksa Sarai , "Naveen N. Rao" , Anil S Keshavamurthy , "David S. Miller" , Jonathan Corbet , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Shuah Khan , Alexei Starovoitov , Daniel Borkmann , Brendan Gregg , Christian Brauner , Aleksa Sarai , netdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH v3 1/2] kretprobe: produce sane stack traces Message-ID: <20181103133329.2160bfd7@vmware.local.home> In-Reply-To: <20181103133021.6676708c@vmware.local.home> References: <20181101083551.3805-1-cyphar@cyphar.com> <20181101083551.3805-2-cyphar@cyphar.com> <20181101204720.6ed3fe37@vmware.local.home> <20181102050509.tw3dhvj5urudvtjl@yavin> <20181102065932.bdt4pubbrkvql4mp@yavin> <20181102091658.1bc979a4@gandalf.local.home> <20181102154325.bt6xoysl4xdl33wd@treble> <20181102121307.32e99414@gandalf.local.home> <20181103220012.55ecd97e671c43e4959c8b62@kernel.org> <20181103091341.3d32683e@vmware.local.home> <20181104013430.9d3e91b8ebbae7dcb6860ef1@kernel.org> <20181103133021.6676708c@vmware.local.home> X-Mailer: Claws Mail 3.15.1 (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 Sat, 3 Nov 2018 13:30:21 -0400 Steven Rostedt wrote: > What I was thinking was to store a count and the functions to be called: > > > [original_return_address] > [function_A] > [function_B] > [function_C] > [ 3 ] > > Then the trampoline that processes the return codes for ftrace (and > kretprobes and everyone else) can simply do: > > count = pop_shadow_stack(); > for (i = 0; i < count; i++) { > func = pop_shadow_stack(); > func(...); > } > return_address = pop_shadow_stack(); > > That way we only need to register a function to the return handler and > it will be called, without worrying about making trampolines. There > will just be a single trampoline that handles all the work. And since the most common case is a single function to call, instead of using a count, we can take advantage that kernel functions are negative numbers and do: [original_return_address] [function_A] ---- long count; count = pop_shadow_stack(); if (count < 0) { func = (void *)count; func(); } else { for (i = 0; i < count; i++) { [...] The unwinder will just need to know how to handle all this :-) -- Steve