Received: by 10.223.176.5 with SMTP id f5csp975345wra; Sat, 3 Feb 2018 14:55:52 -0800 (PST) X-Google-Smtp-Source: AH8x224Hg9CYO14KGsHfbsl+Uv55T47Pnpx6jKyZ03V5MiCjHKto+tX7XvzKfl9CqZCBk8VpsLxk X-Received: by 10.99.42.9 with SMTP id q9mr24948713pgq.325.1517698552390; Sat, 03 Feb 2018 14:55:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517698552; cv=none; d=google.com; s=arc-20160816; b=OyaI+jAfgZ8yaGwIyRyuhhgb+XQG0AxhvAY7qAJOXPzHha+TJfHC+Hoyy8dV7rpAfH 6wLJRTevmtpamrEXmhPLU73sQgB9FTHhzsbpM6S58itFpSeCy0yqaw2JZR/7FeGKccre mDoUfGiNYx6q2cmTNaVBXAA7+cwDRmU+3Scd0TrjHn/Z7Gw9XzOSezXAaKqjyUFQq/CT zqXINZT6gmV/DO1bcIbh/1nl2y9r9BQBEdyX5lrSzFYeOFLrcYSYph92RelsRy7KWa51 HcwGxr3Rc/4GrYa4YkxcjJc+CaAydM2bkMVIw+uiRsiOW34cRKfN9sykLF8iDoW8WH/6 srag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=CCNF3giUxfrm4UP3GX5Vti0h2xDWSj4xqE8hlZQtX2g=; b=aUEuW0t/X0cHc21HRWnQCCY+amnziXaJ/ierAOoM5nn7A+mU9RHjk8MqduwynHbM4n cRqplc6wQLUwAbkwwDKin2vGKQKY0u179VoWYyfWNrrLfTV4sZkMmslBmN/k8i2/oldm L41F7grVpc342JrJ6h9epFGfZRtpEYrCtaIk0YdOr4lXUudh/11EWIc6uIdKRDSrObnQ +X/mwSn8Iz4LTquUUAedWHBT5l5/hVJ/MXMpKg3Tp0crsFVkTu+qZf3rgQT+52is2xao e4WE4J8T+iPPcxYgFlXdT4iwBDaP6Kd6OtdVNFW1SyoVKlRrOqpV2ZykqNaK0zVdezyJ dpYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=nXi5FG0l; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v10-v6si2180071plo.820.2018.02.03.14.55.38; Sat, 03 Feb 2018 14:55:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=nXi5FG0l; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755539AbeBCStn (ORCPT + 99 others); Sat, 3 Feb 2018 13:49:43 -0500 Received: from mail-cys01nam02on0100.outbound.protection.outlook.com ([104.47.37.100]:41422 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752887AbeBCSB1 (ORCPT ); Sat, 3 Feb 2018 13:01:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=CCNF3giUxfrm4UP3GX5Vti0h2xDWSj4xqE8hlZQtX2g=; b=nXi5FG0l+yWG1kSvQoQsvoSbs+zZrGoZ5UXADmpdCYtzHKXS56bFLjeUjc45Q0GgO5pzNZwjWPr+9FcMZzlOBY2cNQ7c2lWoJNxKjKaUaJaFnk/9ZYiGBVBS8xtdII/ReVae9wHTM0d1oAXUZmob5zFGQBDQEIBRm5UqbDlXBgc= Received: from BL0PR2101MB1027.namprd21.prod.outlook.com (52.132.20.161) by BL0PR2101MB1090.namprd21.prod.outlook.com (52.132.24.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.506.1; Sat, 3 Feb 2018 18:00:43 +0000 Received: from BL0PR2101MB1027.namprd21.prod.outlook.com ([fe80::a8da:b5d9:d710:9bf9]) by BL0PR2101MB1027.namprd21.prod.outlook.com ([fe80::a8da:b5d9:d710:9bf9%3]) with mapi id 15.20.0485.006; Sat, 3 Feb 2018 18:00:43 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Josh Poimboeuf , Andy Lutomirski , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , "live-patching@vger.kernel.org" , Ingo Molnar , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 026/110] x86/stacktrace: Make zombie stack traces reliable Thread-Topic: [PATCH AUTOSEL for 4.14 026/110] x86/stacktrace: Make zombie stack traces reliable Thread-Index: AQHTnRjnQM2qb6J8PU6b0fMKf8JPLA== Date: Sat, 3 Feb 2018 18:00:40 +0000 Message-ID: <20180203180015.29073-26-alexander.levin@microsoft.com> References: <20180203180015.29073-1-alexander.levin@microsoft.com> In-Reply-To: <20180203180015.29073-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;BL0PR2101MB1090;7:3BnWLlgQKeraEsVpjNSf+lGjoxautbp1+f9qvsAjRVudU5vADl9j5+UA7KBN0ayM9JpUarTS2bgCDzH3KW4V3p52KDvM3Gs6DdFWBXvPN3d5HMjL8DNu1hCsnnNwuD0FdW4sndVVVqjOV+sDBXRk3opLd5EOmPRYK6UPCFXUAJGcEFcaGPdgbNaqsaksUTNDk0ItvgEsPpVIEBOQTsqSfZEA4NCt0phcX1aWlrpJgeWWEgovDI+QO3OP2DQc9aaa x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: f44c351d-5311-4b42-220a-08d56b300b06 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(2017052603307)(7193020);SRVR:BL0PR2101MB1090; x-ms-traffictypediagnostic: BL0PR2101MB1090: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(20558992708506)(89211679590171)(9452136761055)(42068640409301)(211171220733660); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040501)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231101)(2400082)(944501161)(93006095)(93001095)(6055026)(61426038)(61427038)(6041288)(20161123562045)(20161123560045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:BL0PR2101MB1090;BCL:0;PCL:0;RULEID:;SRVR:BL0PR2101MB1090; x-forefront-prvs: 05724A8921 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(366004)(396003)(39380400002)(39860400002)(346002)(199004)(189003)(2900100001)(5660300001)(316002)(25786009)(4326008)(14454004)(2950100002)(478600001)(966005)(575784001)(107886003)(72206003)(22452003)(10290500003)(186003)(3660700001)(86612001)(76176011)(86362001)(53936002)(3280700002)(106356001)(6436002)(6486002)(59450400001)(81166006)(81156014)(2501003)(6506007)(97736004)(6306002)(26005)(7736002)(6512007)(6346003)(102836004)(105586002)(68736007)(8936002)(5250100002)(305945005)(36756003)(1076002)(6116002)(3846002)(8676002)(110136005)(66066001)(54906003)(2906002)(10090500001)(99286004)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:BL0PR2101MB1090;H:BL0PR2101MB1027.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: Mrc/3dKbvKMjjlnCiePfKe5KJw7IAKNd/YUI+RbgvmVRHQMC0F4dON92dmscaRj0+ZnxR9+OuA1ayLJ4GwEShw== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: f44c351d-5311-4b42-220a-08d56b300b06 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Feb 2018 18:00:40.6752 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR2101MB1090 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Josh Poimboeuf [ Upstream commit 6454b3bdd138dfc640deb5e7b9a0668fca2d55dd ] Commit: 1959a60182f4 ("x86/dumpstack: Pin the target stack when dumping it") changed the behavior of stack traces for zombies. Before that commit, /proc//stack reported the last execution path of the zombie before it died: [] do_exit+0x6f7/0xa80 [] do_group_exit+0x39/0xa0 [] __wake_up_parent+0x0/0x30 [] system_call_fastpath+0x16/0x1b [<00007fd128f9c4f9>] 0x7fd128f9c4f9 [] 0xffffffffffffffff After the commit, it just reports an empty stack trace. The new behavior is actually probably more correct. If the stack refcount has gone down to zero, then the task has already gone through do_exit() and isn't going to run anymore. The stack could be freed at any time and is basically gone, so reporting an empty stack makes sense. However, save_stack_trace_tsk_reliable() treats such a missing stack condition as an error. That can cause livepatch transition stalls if there are any unreaped zombies. Instead, just treat it as a reliable, empty stack. Reported-and-tested-by: Miroslav Benes Signed-off-by: Josh Poimboeuf Cc: Andy Lutomirski Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: live-patching@vger.kernel.org Fixes: af085d9084b4 ("stacktrace/x86: add function for detecting reliable s= tack traces") Link: http://lkml.kernel.org/r/e4b09e630e99d0c1080528f0821fc9d9dbaeea82.151= 3631620.git.jpoimboe@redhat.com Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin --- arch/x86/kernel/stacktrace.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/stacktrace.c b/arch/x86/kernel/stacktrace.c index 60244bfaf88f..4565f31bd398 100644 --- a/arch/x86/kernel/stacktrace.c +++ b/arch/x86/kernel/stacktrace.c @@ -160,8 +160,12 @@ int save_stack_trace_tsk_reliable(struct task_struct *= tsk, { int ret; =20 + /* + * If the task doesn't have a stack (e.g., a zombie), the stack is + * "reliably" empty. + */ if (!try_get_task_stack(tsk)) - return -EINVAL; + return 0; =20 ret =3D __save_stack_trace_reliable(trace, tsk); =20 --=20 2.11.0