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=-3.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 1173CC433E7 for ; Thu, 15 Oct 2020 14:17:34 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 8CA2E20757 for ; Thu, 15 Oct 2020 14:17:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="DzMXFxLk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8CA2E20757 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.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=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=T6yMyxSZAaAkSlvsuLdKKegK5fedz7VOHJby+OTbirI=; b=DzMXFxLks4Su3BnTBicwT+8uA PiVbUrAJbYsSOBzPrmGOc6mHzf6OFtR6EXS04tMK7Jq5uRKfwyjjUmmac1vuiqrR/qwu8N/3kpXHE n8iKEcDy+7sKlOrYAFfShlARVsDDrGgWKmELgRgS/BsthmfII+OHefob9Y1Y1onY7kYugZWQBolZ8 kSuAdIUhU13otCqa10t0l66geOT76JvF5acSbYRZqCEwkq6vWD3+N2/bbLs4bYaoX3z9jMqEGkZqw sAPkJU4/wZrX8cT8PCPuO3lys49mvq4BC6n8O5f+5tbpdcXAHvyrE4s3FG/9tfLiXs0Yl+sWIBUiB 0vtovQzOg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kT43H-0002rc-JB; Thu, 15 Oct 2020 14:16:19 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kT43F-0002r5-IY for linux-arm-kernel@lists.infradead.org; Thu, 15 Oct 2020 14:16:18 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C28FE13D5; Thu, 15 Oct 2020 07:16:16 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.51.4]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5B27B3F719; Thu, 15 Oct 2020 07:16:15 -0700 (PDT) Date: Thu, 15 Oct 2020 15:16:12 +0100 From: Mark Rutland To: Miroslav Benes Subject: Re: [RFC PATCH 0/3] arm64: Implement reliable stack trace Message-ID: <20201015141612.GC50416@C02TD0UTHF1T.local> References: <20201012172605.10715-1-broonie@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201015_101617_680060_EF0AA1B9 X-CRM114-Status: GOOD ( 30.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Catalin Marinas , Mark Brown , Will Deacon , linux-arm-kernel@lists.infradead.org, jpoimboe@redhat.com 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 Thu, Oct 15, 2020 at 03:39:37PM +0200, Miroslav Benes wrote: > Hi, Hi all, > On Mon, 12 Oct 2020, Mark Brown wrote: > > > This patch series aims to implement reliable stacktrace for arm64. > > Reliable stacktrace exists mainly to support live patching, it provides > > a version of stacktrace that checks for consistency problems in the > > traces it generates and provides an error code to callers indicating if > > any problems were detected. > > > > This is a first cut of support for arm64, I've not really even started > > testing it meaningfully at this point. The main thing I'm looking for > > here is that I'm not sure if there are any more potential indicators of > > unrelabile stacks that I'm missing tests for or anything about the > > interfaces that I've misunderstood. > > I'll just copy an excerpt from my notes about the required guarantees. > Written by Josh (CCed, he has better idea about the problem than me > anyway). > > " > The unwinder needs to be able to detect all stack corruption and return > an error. > [ But note that we don't need to worry about unwinding a task's stack > while the task is running, which can be a common source of > "corruption". For livepatch we make sure every task is blocked > (except when checking the current task). ] > > It also needs to: > - detect preemption / page fault frames and return an error > - only return success if it reaches the end of the task stack; for user > tasks, that means the syscall barrier; for kthreads/idle tasks, that > means finding a defined thread entry point > - make sure it can't get into a recursive loop > - make sure each return address is a valid text address > - properly detect generated code hacks like function graph tracing and > kretprobes > " It would be great if we could put something like the above into the kernel tree, either under Documentation/ or in a comment somewhere for the reliable stacktrace functions. AFAICT, existing architectures don't always handle all of the above in arch_stack_walk_reliable(). For example, it looks like x86 assumes unwiding through exceptions is reliable for !CONFIG_FRAME_POINTER, but I think this might not always be true. I was planning to send a mail once I've finished writing a test, but IIUC there are some windows where ftrace/kretprobes detection/repainting may not work, e.g. if preempted after ftrace_return_to_handler() decrements curr_ret_stack, but before the arch termpoline asm restores the original return addr. So we might need something like an in_return_trampoline() to detect and report that reliably. Thanks, Mark. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel