Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp46532imu; Wed, 19 Dec 2018 13:22:24 -0800 (PST) X-Google-Smtp-Source: AFSGD/XelNRQ2TINr3zkJpLaimLTYI0drnMcuL2xaF982n/6zmJ5/o/1zNL7iolhDebk0ZY286T7 X-Received: by 2002:a17:902:aa4c:: with SMTP id c12mr21611755plr.48.1545254544761; Wed, 19 Dec 2018 13:22:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545254544; cv=none; d=google.com; s=arc-20160816; b=RkC9xgEWhE4eiAfuOpYjOEB6Suyj2pHMHKq1oTprwU7YjT2aib00pZbQ7tb5lPJKSz CmyAEJdJL0RjLhhFXOkyAKPOIi1xLlK+VxovVNESgY3d9cncXohcehgWSsfp9SUutOsO ZxsnYcjupu9vUw5IxIwW2CugpOL1R/UfrH6whs/IbttxfGaTlzi6wpDN5N67bYn7MBac na40DCVntPTkrSrdSAA+ASbN3cJJ31nqiEz8cuh3GIbpVE2d5ukS3qePEqDMW/dSJ5pR fVRCYCqUSsldRPvS62zeR/KllMYzR0k8rVrRp8jjDN/KkH87BAqKh/ur1H3owdTjxCtD qEsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=tIB/dUd9ElKQXjOyP0jBb9ur8VSui0md/nlD1FTG09w=; b=df7H4RNCAxWGVz1JCN/yaW9Enk/Z4HH2s4XVz6boXyFfxV0yLuI8fMkaW1MyZvHlLE 67K09WgtweRm5DHh8+41kMS+t0Otfl1lpGiedCnAsP/euWJkEwc8rCjH0St59lUG8ROw apIWPMg3ItftANErulxvMjX4sXYmfqhL+O3oWozC4Bx9pxiQ5LCYdsSkZTowQONU+LUV Lt8Am5QovqXuZcoctRKOGLfhP7vdlEaUPdKYkX8uEXoTzQGjAMDnENSEGCohsna0u0rh zVAF10Kk1LoKA08rAlgwLx9FVEiv/wnHiQtmexjLdkh0nsDeYCyIRVgDjNFDEnR9lYTF 2kXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NCZdPJo3; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c2si14014228plb.152.2018.12.19.13.22.04; Wed, 19 Dec 2018 13:22:23 -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=@linaro.org header.s=google header.b=NCZdPJo3; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730061AbeLSQz6 (ORCPT + 99 others); Wed, 19 Dec 2018 11:55:58 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:38730 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727544AbeLSQz6 (ORCPT ); Wed, 19 Dec 2018 11:55:58 -0500 Received: by mail-wr1-f67.google.com with SMTP id v13so20229709wrw.5 for ; Wed, 19 Dec 2018 08:55:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=tIB/dUd9ElKQXjOyP0jBb9ur8VSui0md/nlD1FTG09w=; b=NCZdPJo3+1PVKnSzm9/e+XPjeeQ1tVIcRTAYJ6qF/8WOBC5o8Dbdvgr+RhsroA+FPI +lSiqHIRoTVlYwSznKb5ChGg2bSiCVjlfCSmGjOIe6eHkKMZUzLeSx+YS83o0czAMgOM JvBJRlPOZUnNmZJ9LmLpks90En7hw48g3b1Ws= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=tIB/dUd9ElKQXjOyP0jBb9ur8VSui0md/nlD1FTG09w=; b=O6+J2qCVggtCZc0PKro5dJthDFGzQksHSHjbbypqvdPMchR3QpkB+IfUtGgszYQydt HzMyv8T2snc5FG+frWJOzxV5svEopc6bWxe+KVkJgoeYZB2BnsAjY9edTL+QliEp0b9G B09OVa/87gxiTyRu7azx8z8jonVXGSpeCKAHPn3I2GC5mDbydOUygKm1jUiCSXb8sqMJ L3/N6N9S3CTLtUx5Vhh6O7IXLPOEOtrXwTu01rg/KQ9xTrP7qoDXev2dTOu36m2CG7Nh ucWrrjTny40phb7uM+j/eM/OsAPAaXs35kTTpm7waAtqD4nGjmj0/QprQW8gF9jvuqsO 7BeA== X-Gm-Message-State: AA+aEWaxgOQG97ksF1/qmXb/mRqDFw4bChJvh3G9hJyQrq9PsLL4lfdg Sn9J7jKLQqHvbADxb1L4H8j1Yg== X-Received: by 2002:adf:a1d2:: with SMTP id v18mr18453414wrv.87.1545238555836; Wed, 19 Dec 2018 08:55:55 -0800 (PST) Received: from holly.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id c12sm4481262wrs.82.2018.12.19.08.55.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 Dec 2018 08:55:55 -0800 (PST) Date: Wed, 19 Dec 2018 16:55:53 +0000 From: Daniel Thompson To: Douglas Anderson Cc: Jason Wessel , Will Deacon , kgdb-bugreport@lists.sourceforge.net, Peter Zijlstra , Christophe Leroy , linux-kernel@vger.kernel.org Subject: Re: [REPOST PATCH v6 4/4] kdb: Don't back trace on a cpu that didn't round up Message-ID: <20181219165553.otpt6ovcshxu7a7p@holly.lan> References: <20181205033828.6156-1-dianders@chromium.org> <20181205033828.6156-5-dianders@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181205033828.6156-5-dianders@chromium.org> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 04, 2018 at 07:38:28PM -0800, Douglas Anderson wrote: > 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 > Acked-by: Daniel Thompson Applied! Thanks. > --- > > Changes in v6: None > Changes in v5: None > Changes in v4: > - Also clear out .debuggerinfo. > - Also clear out .debuggerinfo and .task for the master. > - Remove clearing out in kdb_stub for offline CPUs; it's now redundant. > > Changes in v3: > - Don't back trace on a cpu that didn't round up new for v3. > > Changes in v2: None > > kernel/debug/debug_core.c | 4 ++++ > kernel/debug/kdb/kdb_bt.c | 11 ++++++++++- > kernel/debug/kdb/kdb_debugger.c | 7 ------- > 3 files changed, 14 insertions(+), 8 deletions(-) > > diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c > index 1fb8b239e567..5cc608de6883 100644 > --- a/kernel/debug/debug_core.c > +++ b/kernel/debug/debug_core.c > @@ -592,6 +592,8 @@ static int kgdb_cpu_enter(struct kgdb_state *ks, struct pt_regs *regs, > arch_kgdb_ops.correct_hw_break(); > if (trace_on) > tracing_on(); > + kgdb_info[cpu].debuggerinfo = NULL; > + kgdb_info[cpu].task = NULL; > kgdb_info[cpu].exception_state &= > ~(DCPU_WANT_MASTER | DCPU_IS_SLAVE); > kgdb_info[cpu].enter_kgdb--; > @@ -724,6 +726,8 @@ static int kgdb_cpu_enter(struct kgdb_state *ks, struct pt_regs *regs, > if (trace_on) > tracing_on(); > > + kgdb_info[cpu].debuggerinfo = NULL; > + kgdb_info[cpu].task = NULL; > kgdb_info[cpu].exception_state &= > ~(DCPU_WANT_MASTER | DCPU_IS_SLAVE); > kgdb_info[cpu].enter_kgdb--; > 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(); > } > diff --git a/kernel/debug/kdb/kdb_debugger.c b/kernel/debug/kdb/kdb_debugger.c > index 15e1a7af5dd0..53a0df6e4d92 100644 > --- a/kernel/debug/kdb/kdb_debugger.c > +++ b/kernel/debug/kdb/kdb_debugger.c > @@ -118,13 +118,6 @@ int kdb_stub(struct kgdb_state *ks) > kdb_bp_remove(); > KDB_STATE_CLEAR(DOING_SS); > KDB_STATE_SET(PAGER); > - /* zero out any offline cpu data */ > - for_each_present_cpu(i) { > - if (!cpu_online(i)) { > - kgdb_info[i].debuggerinfo = NULL; > - kgdb_info[i].task = NULL; > - } > - } > if (ks->err_code == DIE_OOPS || reason == KDB_REASON_OOPS) { > ks->pass_exception = 1; > KDB_FLAG_SET(CATASTROPHIC); > -- > 2.20.0.rc1.387.gf8505762e3-goog >