Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2545407imu; Tue, 6 Nov 2018 17:05:03 -0800 (PST) X-Google-Smtp-Source: AJdET5eKT5MuAnFMXL5KLn20ejg7o2AHqpjBSbyTXpsjToeUxSufuNf36hhM8kjLJteALBiQoZIl X-Received: by 2002:a17:902:9f91:: with SMTP id g17-v6mr8800725plq.27.1541552703373; Tue, 06 Nov 2018 17:05:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541552703; cv=none; d=google.com; s=arc-20160816; b=AfC2+VJq9GP3tYwL2IY9lngsSM3RcixUqx1Gkfh9R9zYOr/ju0saHZbLQZR9tFwVUN Dx2YOqGmCV4yHV7Pn6HGQEKib0XEVz+5BTRgbNhA0Rz6m4E7r0YGQA8j1bEJwaQXpD9H 3Prxkg/e5rLkZ8oiwfTgJwNoL1A/S72vt58zqDMElGk9Lx2TzvLsvm/mkIo2dva/bGOs T5fNUDHRlkycycSfCnJxO71oKKVqL/tMHCHzTstSBjX7K810pQUeyDfXfpJMN0tpw3yQ 5w7k8rUM4nVqbT2cuRDn6kEqEYpdRmwrJJIeDf62szaJhK4fg5ZOwzo5MaDQC8fpJctK 2tbg== 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=IBgaqhFzeF1TpKh7XpgYVYLbY8p4f3B3hZXickKUZUg=; b=cKZPUDQ3ouhOGAJ+/tSYklHWHVkmrT9NQqXGToz7HQVMCAmt0zfHxrFh0RlKjc6ye0 PHE6ShyWwqbRrNAlh+aNPVeCINdePkDcqW8ZPjAls5XRMuiNMGMb5nld89Wm3vUC9k06 6NbYE14Wg4Zb9FQTTUY/7cyCk4ActzJAhpvI7MLRi93QxTStiBSraiJALcCD6BvyidtI D/wpfg+0W0TInuvnrjUENX1s9/Xz04XILdoX0wNpSitFvUy6fVkaMzyc98rFOsNW6JSF kL2R8Cx3bRQ3d/Y9cBJKzL+ZaWhc23xPiCLZb4V515i4Q8qI+ZLJQUb5fWgZsFMcA1z4 a72w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=kgw3jYni; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c7-v6si10954430pfc.153.2018.11.06.17.04.47; Tue, 06 Nov 2018 17:05:03 -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=@chromium.org header.s=google header.b=kgw3jYni; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389005AbeKGKcU (ORCPT + 99 others); Wed, 7 Nov 2018 05:32:20 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:36894 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387697AbeKGKcT (ORCPT ); Wed, 7 Nov 2018 05:32:19 -0500 Received: by mail-pf1-f193.google.com with SMTP id u13-v6so6940954pfm.4 for ; Tue, 06 Nov 2018 17:04:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IBgaqhFzeF1TpKh7XpgYVYLbY8p4f3B3hZXickKUZUg=; b=kgw3jYnioIm9CljR2FvmQhiREM4Bkk0e1ODD4XmY6reyfDOK2Kh+cjQX38xgUJyQYg 0O8MwzsWJ+zXc3Yj7C8pStYq6L9y+MsoiSFKFn2y46ZBRXAf/OYbLdODjhkRMN5m32AV d2eoyeh09XMfWfrBoZ8MqXIarjFiEnvUu/HgU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IBgaqhFzeF1TpKh7XpgYVYLbY8p4f3B3hZXickKUZUg=; b=DcWWkp2OSA+KcSpkXAkQSVd4hvPYRddTcfhwjgsFmpZar81PVLUsPbH8Xu8KP0CWFT RJmLlFaBQNU+h04BFIzFgufKahiBtO4c5XtTP0utVbm7t6LUKTsxKflhbcCUn/4iHtSo ZVm/4MoyxOZKgJVL9/3Yb0HIEOoI49kzvrnRzXRU7h8WV71ArwcFiKjnzowlCqGQQI8A sZYub9t/Y67Fis6ZUK402tAa9OTzBxQVOnHYszlfWKDZc9+hPPitBjineJHozChl3s9T d92kGdNfWzJ1sluHJIm55HgMowEGeCx+i7H1OTYAUPn6pM7ZxfQk+2woTdA6Ji8mtIwX dySQ== X-Gm-Message-State: AGRZ1gLdTBODtWFs4Iq/OSruCiFw9dlffVbLIr0keqPnuRSuGphZWbRy RQECl5nbFgFVXUXrWvIAk4oUuF57GRA= X-Received: by 2002:a63:fd53:: with SMTP id m19mr6879798pgj.340.1541552657619; Tue, 06 Nov 2018 17:04:17 -0800 (PST) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:c8e0:70d7:4be7:a36]) by smtp.gmail.com with ESMTPSA id v37sm30134695pgn.5.2018.11.06.17.04.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 17:04:17 -0800 (PST) From: Douglas Anderson To: Jason Wessel , Daniel Thompson Cc: kgdb-bugreport@lists.sourceforge.net, Peter Zijlstra , Douglas Anderson , Christophe Leroy , linux-kernel@vger.kernel.org Subject: [PATCH v3 4/4] kdb: Don't back trace on a cpu that didn't round up Date: Tue, 6 Nov 2018 17:00:28 -0800 Message-Id: <20181107010028.184543-5-dianders@chromium.org> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog In-Reply-To: <20181107010028.184543-1-dianders@chromium.org> References: <20181107010028.184543-1-dianders@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If you have a CPU that fails to round up and then run 'btc' you'll end up crashing in kdb becaue we dereferenced NULL. Let's add a check. It's wise to also set the task to NULL when leaving the debugger so that if we fail to round up on a later entry into the debugger we won't backtrace a stale task. Signed-off-by: Douglas Anderson --- Changes in v3: - New for v3. Changes in v2: None kernel/debug/debug_core.c | 1 + kernel/debug/kdb/kdb_bt.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c index 324cba8917f1..08851077c20a 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c @@ -587,6 +587,7 @@ static int kgdb_cpu_enter(struct kgdb_state *ks, struct pt_regs *regs, kgdb_info[cpu].exception_state &= ~(DCPU_WANT_MASTER | DCPU_IS_SLAVE); kgdb_info[cpu].enter_kgdb--; + kgdb_info[cpu].task = NULL; smp_mb__before_atomic(); atomic_dec(&slaves_in_kgdb); dbg_touch_watchdogs(); diff --git a/kernel/debug/kdb/kdb_bt.c b/kernel/debug/kdb/kdb_bt.c index 7921ae4fca8d..7e2379aa0a1e 100644 --- a/kernel/debug/kdb/kdb_bt.c +++ b/kernel/debug/kdb/kdb_bt.c @@ -186,7 +186,16 @@ kdb_bt(int argc, const char **argv) kdb_printf("btc: cpu status: "); kdb_parse("cpu\n"); for_each_online_cpu(cpu) { - sprintf(buf, "btt 0x%px\n", KDB_TSK(cpu)); + void *kdb_tsk = KDB_TSK(cpu); + + /* If a CPU failed to round up we could be here */ + if (!kdb_tsk) { + kdb_printf("WARNING: no task for cpu %ld\n", + cpu); + continue; + } + + sprintf(buf, "btt 0x%px\n", kdb_tsk); kdb_parse(buf); touch_nmi_watchdog(); } -- 2.19.1.930.g4563a0d9d0-goog