Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4848891rdb; Tue, 12 Dec 2023 10:56:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IEtwqQO4WcxYlkbxV+LYxpSmwlrghv/QIKzFdzZ4XSOcoV5HKa6ALigvW9OpR5YPPW4wYDG X-Received: by 2002:a17:903:40ca:b0:1d0:9e13:8b89 with SMTP id t10-20020a17090340ca00b001d09e138b89mr4283850pld.82.1702407377829; Tue, 12 Dec 2023 10:56:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702407377; cv=none; d=google.com; s=arc-20160816; b=UQaNv32RGIGqaVrJvNVRWPPXi6yoVbCMgalAPr0o8UNIzeokpZ05G/gfJ/+AD29iia 2T6PEO2MH3ADLzAnIwM7SsvT8odb1BjfgKPqWJWO3ID4vVs9ycEGt1O80yl0haSDzQQP Mdqw8A6sikAzTX3bLOXa1Bm9wMciN23xTPgAGe6O14ICAM1IdInfeLcZ/lwBz3bhPmpB mFpqewjf2CHl0XIRcQa2Q2FhrviHOynK3lIlJMMI2kR75duHLROntk3NDSkcRavFRSbh BmAA6pBnckN48mM67uB2V9TK8hpm7UKCXoaq7bN7oaQI5iRJCtSxJlWaJp7tYFVP2Ce3 m8og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=WY8HTDQ70rR2aZzIILj2Anm5g5sqPGsUFhfJC3/aJH4=; fh=A0ToedsxzAPk0EcbPqFMvJ7CAqN6OxkwN9+xcPt4NUM=; b=YWFg2giYvdi/mxdPPf1y2FhQXMYuqsNjjo3l+6T8Q+iXkTdStU8GrEXdFw3rnKs8NP J0J9H6TMQMJ5T5IN7WEjwMzVw6CdeHytPdzDPXk8+IN7U5PuKgrYUwi7+m9pEVIfGBqS g9anpULWN3Yit324CG5EYOxqLUsJQQ+Yr27Rr7Fk3jJkPIMIYu0kI93ydfZDfd35TVe+ BisPQ4u9QWVFoQRHE+X8jX0NCAX6qX4BIzoiJ+QPXOHziyHloK4TtfgYZizjntLzcTU/ V1OxDdccBMmAxS47/fQGC18XSEOLampQ2jaMJTILonAgHM+zv9UimuSMLfoUk/Snjzzg YBLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=iJMGTlir; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id jb11-20020a170903258b00b001d00594c6e6si8207674plb.106.2023.12.12.10.56.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 10:56:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=iJMGTlir; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 9B06C802F726; Tue, 12 Dec 2023 10:56:12 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376723AbjLLSzy (ORCPT + 99 others); Tue, 12 Dec 2023 13:55:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376880AbjLLSzq (ORCPT ); Tue, 12 Dec 2023 13:55:46 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE4D791; Tue, 12 Dec 2023 10:55:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1702407328; x=1703012128; i=rwahl@gmx.de; bh=IHz6BQHqma+jxYrd5WICx4pHCK4/jGS4y2B8Mb5NueA=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=iJMGTlirtY6EwqRCUDDUytisGkGaTEkGc2xIs92K+4mHLlzpSn9JR8M29/9B0Fu8 nJqik5TOJWK29NxrtBEJ0DMNxZVvpzQQbGMD0GYubuVKCh87mYKxbLAzsPhJDcw6r o4gMCRl8EthKiJR+swscGVmzPgOAidF01AS6h9lcPu50Oehz1MyUFugPhq2EWcEph 2puqjToyhWwIRPGJGOY/qJQbP/gkkJ2jFk/9AmiTOWouEMQMkHmqsDcSyjlqSlz6W a9s6cpGyejjrLzp74HfL2Ck6PBACAeGnWnXWFVN31k8jIkHyIb/A07jjPWjd46Fs6 CKg6b956VwqCw/nh5A== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from rohan.localdomain ([84.156.159.24]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MtOKi-1rU5zt44zO-00upKL; Tue, 12 Dec 2023 19:55:28 +0100 From: Ronald Wahl To: rwahl@gmx.de Cc: linux-kernel@vger.kernel.org, Ronald Wahl , Thomas Gleixner , Josh Poimboeuf , Peter Zijlstra , linux-arch@vger.kernel.org Subject: [PATCH v2] stacktrace: check whether task has a stack before saving it Date: Tue, 12 Dec 2023 19:55:18 +0100 Message-ID: <20231212185518.196361-1-rwahl@gmx.de> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X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8j1joJYrFbirTQrrVuMV4Oq5n EZRwoiF1CO3CEIunGMokhs9Bg4OKPnovioXQUzP9QQiE+xt5Iai9JntisfUY5zo2T6ODcjhVA rs6X8JGjmYaXw2D/rc7ga4F+2CwX9RtcQ4KTQ/Rfs20JKtdROpIwR+FZ17T7E605FJUudhU9/ FinXk93y28m9gzKvY68WxQ0Zo/Q= X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 12 Dec 2023 10:56:12 -0800 (PST) From: Ronald Wahl I encountered a crash on ARM32 when trying to dump the stack of some zombie process. This is caused by a missing check whether the task actually has a valid stack. This commit adds this check. Commit 214d8ca6ee85 ("stacktrace: Provide common infrastructure") introduced this check for platforms that define CONFIG_ARCH_STACKWALK but ARM32 is not one of them. Cc: Thomas Gleixner Cc: Josh Poimboeuf Cc: Peter Zijlstra Cc: linux-arch@vger.kernel.org Signed-off-by: Ronald Wahl =2D-- V2: - added missing put_task_stack(task) to avoid memory leak kernel/stacktrace.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/stacktrace.c b/kernel/stacktrace.c index 9ed5ce989415..0bb67bd633c6 100644 =2D-- a/kernel/stacktrace.c +++ b/kernel/stacktrace.c @@ -298,7 +298,11 @@ unsigned int stack_trace_save_tsk(struct task_struct = *task, .skip =3D skipnr + (current =3D=3D task), }; + if (!try_get_task_stack(task)) + return 0; + save_stack_trace_tsk(task, &trace); + put_task_stack(task); return trace.nr_entries; } =2D- 2.43.0