From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D30B5C433ED for ; Mon, 5 Apr 2021 14:58:26 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 66FE7613B4 for ; Mon, 5 Apr 2021 14:58:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 66FE7613B4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:Cc:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ZxjomW0qe3c9mgHoaRRmA/G9AKtY1JF1kzHEXJR/aMk=; b=ar6V5YNoJmy7hQukPpzpZHrIY DXytxTzzcIvsyQEgoHmaZeMHoRyRKWEjeNhO2AmmQb1ixblO8KxclEGJyVt4pDuNU4UpNUcimE+SX yvQYmTGE3/SWaiNgnELzzvoTcKodItPzs12u/v7GfcvqtZABqEeXhtHqzOvQFdMH9oXS1tWRhB2FH K9KvfvSGMlCRaGV279IoTeoD3cFcVZjawvPUKaXdkDPeuaEC7seBBPuhn4hXTErxcLYuoBKizxhkB hoZGJMnBH/iCUaOWDCqGTZkO1E/jN62sYuiMmeqaduSX1Auf+lHU/w6jeF/lwplES++rG08De5wnN eqGi8XrIw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lTQet-00HRI6-Sg; Mon, 05 Apr 2021 14:56:55 +0000 Received: from linux.microsoft.com ([13.77.154.182]) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lTQep-00HRHg-Ir for linux-arm-kernel@lists.infradead.org; Mon, 05 Apr 2021 14:56:53 +0000 Received: from [192.168.254.32] (unknown [47.187.194.202]) by linux.microsoft.com (Postfix) with ESMTPSA id B17FA20B5680; Mon, 5 Apr 2021 07:56:49 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com B17FA20B5680 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1617634610; bh=Pd2aEm4Jogei2ZP/WP/ICidNHaEQSmRltw/NyI+NufA=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=PN2nKehFJ9UP22EHuP6ZMv55ZjU8fNNTGhCuv/ZMmS5n9KGJT+TtiB9m88HKcX2UR it+JvqplG/kywOJpuij1/XIytSzKTzpZGL+/L0QiwASZyHAUUIi/OanCbrLApZIrXU grYoQwFXw5NXSJtTUqJHiqbvi3utlD6RbCAzrssk= Subject: Re: [RFC PATCH v1 0/4] arm64: Implement stack trace reliability checks To: Masami Hiramatsu Cc: Josh Poimboeuf , mark.rutland@arm.com, broonie@kernel.org, jthierry@redhat.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org References: <77bd5edeea72d44533c769b1e8c0fea7a9d7eb3a> <20210330190955.13707-1-madvenka@linux.microsoft.com> <20210403170159.gegqjrsrg7jshlne@treble> <20210405222436.4fda9a930676d95e862744af@kernel.org> From: "Madhavan T. Venkataraman" Message-ID: <7dda9af3-1ecf-5e6f-1e46-8870a2a5e550@linux.microsoft.com> Date: Mon, 5 Apr 2021 09:56:48 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210405222436.4fda9a930676d95e862744af@kernel.org> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210405_155652_019169_9F7B2F59 X-CRM114-Status: GOOD ( 22.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 4/5/21 8:24 AM, Masami Hiramatsu wrote: > Hi Madhaven, > > On Sat, 3 Apr 2021 22:29:12 -0500 > "Madhavan T. Venkataraman" wrote: > > >>>> Check for kretprobe >>>> =================== >>>> >>>> For functions with a kretprobe set up, probe code executes on entry >>>> to the function and replaces the return address in the stack frame with a >>>> kretprobe trampoline. Whenever the function returns, control is >>>> transferred to the trampoline. The trampoline eventually returns to the >>>> original return address. >>>> >>>> A stack trace taken while executing in the function (or in functions that >>>> get called from the function) will not show the original return address. >>>> Similarly, a stack trace taken while executing in the trampoline itself >>>> (and functions that get called from the trampoline) will not show the >>>> original return address. This means that the caller of the probed function >>>> will not show. This makes the stack trace unreliable. >>>> >>>> Add the kretprobe trampoline to special_functions[]. >>>> >>>> FYI, each task contains a task->kretprobe_instances list that can >>>> theoretically be consulted to find the orginal return address. But I am >>>> not entirely sure how to safely traverse that list for stack traces >>>> not on the current process. So, I have taken the easy way out. >>> >>> For kretprobes, unwinding from the trampoline or kretprobe handler >>> shouldn't be a reliability concern for live patching, for similar >>> reasons as above. >>> >> >> Please see previous answer. >> >>> Otherwise, when unwinding from a blocked task which has >>> 'kretprobe_trampoline' on the stack, the unwinder needs a way to get the >>> original return address. Masami has been working on an interface to >>> make that possible for x86. I assume something similar could be done >>> for arm64. >>> >> >> OK. Until that is available, this case needs to be addressed. > > Actually, I've done that on arm64 :) See below patch. > (and I also have a similar code for arm32, what I'm considering is how > to unify x86/arm/arm64 kretprobe_find_ret_addr(), since those are very > similar.) > > This is applicable on my x86 series v5 > > https://lore.kernel.org/bpf/161676170650.330141.6214727134265514123.stgit@devnote2/ > > Thank you, > > I took a brief look at your changes. Looks reasonable. However, for now, I am going to include the kretprobe_trampoline in the special_functions[] array until your changes are merged. At that point, it is just a matter of deleting kretprobe_trampoline from the special_functions[] array. That is all. I hope that is fine with everyone. Madhavan _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel