Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2005308ybh; Fri, 17 Jul 2020 07:07:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyj+6X9Qby8fc+D0XeTFtds3ho6e5hjmi5bWyC/Qlqf0w5Jb95eK3USL1PqSRxdFa0Hxw/ X-Received: by 2002:a17:906:c452:: with SMTP id ck18mr9208751ejb.415.1594994837644; Fri, 17 Jul 2020 07:07:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594994837; cv=none; d=google.com; s=arc-20160816; b=aZEI/Cik1G54i9qJ0HXX3DCZKsDulE27/7c2HRN95Kfcszy6IzVnVTpd3sT464/myT sLYPI/notdFPQJy2o2he7+GiyvJcwPLcZi+Bi+R5vUl/QmAdIsZ9cBw1+Wv2KqRnKTGq xfnttZkGI7Xxv6DaP4jria+e0iljilLP4yOthHP0JmDCyPqe/dgXpi2J5kIAXFAjyGVS zCww56IzuNUvey5YgLe+D8WxpE8w9y9lh11qyAZy7H1VeeNeEUqSfxmcld7fYAbt8l4t LGokA/9Cci/ptxJT00NGSufAOYSwRefXOgZrDK/mZYBcb8pwvKAWeNS/vwl4lHumDLdN PI0g== 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:date:subject:cc:to:from :dkim-signature; bh=RPasInMPBQhfNqDDCSClEwKnR8yJcnj0gbkGKH+IRS8=; b=nmZjxrS9KXAbSFum8YDlMt7KqyZL13UNMb+bMUy3RUxFMt+sPHD67JuB/a52LC/1lm iD+/T8C4s6sZpevdxYKS2/7DNCf57xItrcmEKjNvG4mbP1JGCmzxbSPKQdoianmxz1iQ 6pyvMhPuuPtPhwLqp7mYfy5lDImBUt63DLct6J4PAYnId4vHzdfJTFyxJjBOxPdv953j r57sLAmRcNXFwxpAZQsFsH29v/f3XJ+pvgx5QUq0dO31jZ5+/r3SduT9+bPgluGs2JK8 Z0jdMDU97vxuBUxL8LiHlBZ7qOdTl2bpEd31sLJIaPwCrH1c83A5xW8BbJoTkhW8Vq8m 9Dyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OP7mVcVA; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bx21si4642159ejc.644.2020.07.17.07.06.54; Fri, 17 Jul 2020 07:07:17 -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=@redhat.com header.s=mimecast20190719 header.b=OP7mVcVA; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727090AbgGQOEh (ORCPT + 99 others); Fri, 17 Jul 2020 10:04:37 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:29344 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726893AbgGQOEg (ORCPT ); Fri, 17 Jul 2020 10:04:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594994675; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RPasInMPBQhfNqDDCSClEwKnR8yJcnj0gbkGKH+IRS8=; b=OP7mVcVAUlVoII1FJ6HUXdYwoo23W6YcLuVgYz3SGPN/OVa6q53Q+Wh0HHlBfga0vubNUk nm6YfEEYqwYp1k93bkD/Vq+IUxWfjwIw9eA3b6oNdZGaH0fvrZJjK7d2aKYuX97tEJjnHH Se538EfGfDhZH3YUxSVnG90Iv0IuYqs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-144-RcK2A-9mM22zz-CDwjqxRg-1; Fri, 17 Jul 2020 10:04:33 -0400 X-MC-Unique: RcK2A-9mM22zz-CDwjqxRg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 24D3A18A1DE5; Fri, 17 Jul 2020 14:04:32 +0000 (UTC) Received: from treble.redhat.com (ovpn-118-144.rdu2.redhat.com [10.10.118.144]) by smtp.corp.redhat.com (Postfix) with ESMTP id 74C2A1EA; Fri, 17 Jul 2020 14:04:31 +0000 (UTC) From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Peter Zijlstra , Wang ShaoBo Subject: [PATCH 2/2] x86/stacktrace: Fix reliable check for empty user task stacks Date: Fri, 17 Jul 2020 09:04:26 -0500 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If a user task's stack is empty, or if it only has user regs, ORC reports it as a reliable empty stack. But arch_stack_walk_reliable() incorrectly treats it as unreliable. That happens because the only success path for user tasks is inside the loop, which only iterates on non-empty stacks. Generally, a user task must end in a user regs frame, but an empty stack is an exception to that rule. Thanks to commit 71c95825289f ("x86/unwind/orc: Fix error handling in __unwind_start()"), unwind_start() now sets state->error appropriately. So now for both ORC and FP unwinders, unwind_done() and !unwind_error() always means the end of the stack was successfully reached. So the success path for kthreads is no longer needed -- it can also be used for empty user tasks. Reported-by: Wang ShaoBo Signed-off-by: Josh Poimboeuf --- arch/x86/kernel/stacktrace.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/arch/x86/kernel/stacktrace.c b/arch/x86/kernel/stacktrace.c index 6ad43fc44556..2fd698e28e4d 100644 --- a/arch/x86/kernel/stacktrace.c +++ b/arch/x86/kernel/stacktrace.c @@ -58,7 +58,6 @@ int arch_stack_walk_reliable(stack_trace_consume_fn consume_entry, * or a page fault), which can make frame pointers * unreliable. */ - if (IS_ENABLED(CONFIG_FRAME_POINTER)) return -EINVAL; } @@ -81,10 +80,6 @@ int arch_stack_walk_reliable(stack_trace_consume_fn consume_entry, if (unwind_error(&state)) return -EINVAL; - /* Success path for non-user tasks, i.e. kthreads and idle tasks */ - if (!(task->flags & (PF_KTHREAD | PF_IDLE))) - return -EINVAL; - return 0; } -- 2.25.4