Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp3891251pxy; Tue, 4 May 2021 12:15:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAhWEfBxBNjek+VvAWT/WYey5VFUf85LiFBJRiOx4tmyRl6o3XHT3nAnVA1iLphSNOom2l X-Received: by 2002:a17:90a:7063:: with SMTP id f90mr6981460pjk.95.1620155736095; Tue, 04 May 2021 12:15:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620155736; cv=none; d=google.com; s=arc-20160816; b=FXru8HImwwwdJ3BbIfnMdbrhSm7fLMKRxHxaETj/fnhR/ktZx7jKrYkGLF1eb4R/kw l2xWmMM8ivzK3LZOJPPfBLBRU/rCrG7D71DqJOENtO83vdCBAkJwACqjGc1ds4v4AnBJ DHcbmwdDGBFbTn5yQLyPb+ZZLPZlGJlmuFco2KAn7BY01/uM1+Rq5C1mSQD6w7tUkgby AcpscDIm2n8Ksk88iy5iRhmr52ORM2pBJkjJtf2XZXBKgy++QRP7T0dS7k2yInE39l8T am4iHFUno3OhWupH+RAwyH6HKfi3UzipiSxdOzo/hQCJR4b/33Gt5anx2L/9soxA71sV hD9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:dkim-filter; bh=NT93qR5y4vJEyN4TlNFBZ7epv4aqQ9wRwRPw+CZEeh0=; b=k3wOyGNL26S6tDsan8VYAJ/Dd8DmBz9Ic4aslgCUfhLDp/Or7pndg88qoV+2Y05X/H 5uzvCc6GND0wUc2izIYlj5q+5d9iJ2hbfEVYjFu6ecSah3X7gmvhRefoc68sAKpvycXc RmMqpa0MmsqM3/KgzVi9yvf0317LqbL9r4eHVsW43ZV0CajfHqdLf6hlqZkpb9hLwBnm Uv95sMC6EO1Ma36nrxGVSLkDxeIsJM0zKxxGn/QZCt8tu58uNUL7RWsEoGgoh5Szhsj9 9LtMT21isqdqfvrNkEyS6Tj1mQTcuBTxt8S/HERuRj7TqvffTpcq9Go5qYlPyZbcXPvR 2jvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b="c4Tu84/w"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o4si19002473pjg.78.2021.05.04.12.15.22; Tue, 04 May 2021 12:15:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b="c4Tu84/w"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232109AbhEDTPQ (ORCPT + 99 others); Tue, 4 May 2021 15:15:16 -0400 Received: from linux.microsoft.com ([13.77.154.182]:58312 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231604AbhEDTPP (ORCPT ); Tue, 4 May 2021 15:15:15 -0400 Received: from [192.168.254.32] (unknown [47.187.223.33]) by linux.microsoft.com (Postfix) with ESMTPSA id F1D5E20B7178; Tue, 4 May 2021 12:14:19 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com F1D5E20B7178 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1620155660; bh=NT93qR5y4vJEyN4TlNFBZ7epv4aqQ9wRwRPw+CZEeh0=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=c4Tu84/wv4NIzOPdh8fTtWgwZHEwqPxQdHhJSjz1xd7HvjwI9ScVDcvHvbJF16QuD xacGTdmjxVwMCyloctrINa9KX9kO/eV0zszLDjgO71fR6lOUexVEiKp5niDkeBTGhY CIS7a8e2TaWWqVKaxS4Yv6x8082R2iAnK/a9pez8= Subject: Re: [RFC PATCH v3 1/4] arm64: Introduce stack trace reliability checks in the unwinder To: Mark Brown Cc: jpoimboe@redhat.com, mark.rutland@arm.com, jthierry@redhat.com, catalin.marinas@arm.com, will@kernel.org, jmorris@namei.org, pasha.tatashin@soleen.com, linux-arm-kernel@lists.infradead.org, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org References: <65cf4dfbc439b010b50a0c46ec500432acde86d6> <20210503173615.21576-1-madvenka@linux.microsoft.com> <20210503173615.21576-2-madvenka@linux.microsoft.com> <20210504155056.GB7094@sirena.org.uk> From: "Madhavan T. Venkataraman" Message-ID: <66680284-8c80-1434-6c49-d86a47767168@linux.microsoft.com> Date: Tue, 4 May 2021 14:14:19 -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: <20210504155056.GB7094@sirena.org.uk> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/4/21 10:50 AM, Mark Brown wrote: > On Mon, May 03, 2021 at 12:36:12PM -0500, madvenka@linux.microsoft.com wrote: > >> + /* >> + * First, make sure that the return address is a proper kernel text >> + * address. A NULL or invalid return address probably means there's >> + * some generated code which __kernel_text_address() doesn't know >> + * about. Mark the stack trace as not reliable. >> + */ >> + if (!__kernel_text_address(frame->pc)) { >> + frame->reliable = false; >> + return 0; >> + } > > Do we want the return here? It means that... > >> + >> #ifdef CONFIG_FUNCTION_GRAPH_TRACER >> if (tsk->ret_stack && >> - (ptrauth_strip_insn_pac(frame->pc) == (unsigned long)return_to_handler)) { >> + frame->pc == (unsigned long)return_to_handler) { >> struct ftrace_ret_stack *ret_stack; >> /* >> * This is a case where function graph tracer has >> @@ -103,11 +117,10 @@ int notrace unwind_frame(struct task_struct *tsk, struct stackframe *frame) >> if (WARN_ON_ONCE(!ret_stack)) >> return -EINVAL; >> frame->pc = ret_stack->ret; >> + frame->pc = ptrauth_strip_insn_pac(frame->pc); >> } > > ...we skip this handling in the case where we're not in kernel code. I > don't know off hand if that's a case that can happen right now but it > seems more robust to run through this and anything else we add later, > even if it's not relevant now changes either in the unwinder itself or > resulting from some future work elsewhere may mean it later becomes > important. Skipping futher reliability checks is obviously fine if > we've already decided things aren't reliable but this is more than just > a reliability check. > AFAICT, currently, all the functions that the unwinder checks do have valid kernel text addresses. However, I don't think there is any harm in letting it fall through and make all the checks. So, I will remove the return statement. Thanks! Madhavan