Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7124512imu; Mon, 3 Dec 2018 08:05:55 -0800 (PST) X-Google-Smtp-Source: AFSGD/WbzWlsDarJQRCyELsKBg/kOXmrQ7WQxUKSrMUApWnFB82EMjChVBFmGOX8CtCR3F8MHjSj X-Received: by 2002:a63:170c:: with SMTP id x12mr13323162pgl.364.1543853155744; Mon, 03 Dec 2018 08:05:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543853155; cv=none; d=google.com; s=arc-20160816; b=i74CVHESyBM4dIsDSL6iQ8kiX/Akuqyvhb5AJ49WeeM+77jyUvmTXPalSx21apKYAP R38cF6aSG1u5SpvhTsAN2nk/o0u8VBBlDki6QBhXoEyKflKGjnTX31Zq+HjW7c1m5vo6 U9zrL0MK17GdMMsvxbyUAQqY7/0kkWP6XHqEu9ZIkPXsfkYYDKhHhOJVZ8XnXfyeQ1i0 Zl3Gx0RYIxVU+239wi62Z2HyFsJOZz6RtMYlUNLgTv7cIxUvWUPvK9oxRdQ7Eua0z9/j n2Z9OLiAhv4nlTQ01bzygj5oefPSp6tn/TASad5odvZoR31EeLiEgmCxJN+a6HCX7NJM dRBg== 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=06FJKPDjtfdMx+1q4EAWwbubvg4EI5lJBwYBjs/Hhoc=; b=HhsJ09AX1459p2Mx4mEeAf0WnkIrs36dP4tfKcPHHG5bY6DY4jvJR08kt9UA6DbAc7 xu94vR0xj6Gk5Lr23FPCBZ0Qt0niMVCjWkHhm3tgrh0G95H35K4M1eJ9fRItaNqM1Fh5 azZFWRr0YuK5icXeCEhw1VlXA8RiMQsy+jJ0sHtJe5v/EzdEfG0ok+rtMilkWuKs9OPP goXEWMZPiVn85/J9tpOf7dl2gPJ21ibYIJigr8a6J9sHjY+TWM0BzVjO7sc2RlgOHMq5 02euShqyaJoRotD4H62Z3mOnFBlgsDIAyMp5lwK32gTo682bCV09kQoT0PXGV/lPiJy8 YwRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fCBRVLk7; 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 e9si13611677plt.330.2018.12.03.08.05.26; Mon, 03 Dec 2018 08:05:55 -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=fCBRVLk7; 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 S1726664AbeLCQD3 (ORCPT + 99 others); Mon, 3 Dec 2018 11:03:29 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:41130 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726615AbeLCQD3 (ORCPT ); Mon, 3 Dec 2018 11:03:29 -0500 Received: by mail-wr1-f65.google.com with SMTP id x10so12750466wrs.8 for ; Mon, 03 Dec 2018 08:03:22 -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=06FJKPDjtfdMx+1q4EAWwbubvg4EI5lJBwYBjs/Hhoc=; b=fCBRVLk7e8zijVcqeaatmESL/CPzITcZ9BXXxPmbydWZ/81hPfLIwCLV4M1C033b7n mT5Ux9blJd/exgMey+EVMUDc9vH7daj84qEYPlGh9KClcwKgWMityLGThStxa9rmN/ke MEE0B5CmK32znMmwGxHG3zbQ6vDV8xzC8APV8= 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=06FJKPDjtfdMx+1q4EAWwbubvg4EI5lJBwYBjs/Hhoc=; b=J0ZGwBATx2GgljmvMe3ARQfpmf4666gyJPLEKBn7PgRC8kdmXg6xSLY9FCNS2rrBKa NFa3BM+XuXMsw/GDEKfbsJgxVKRyCQdNVvl0v1WVoDLj+m2ZisiatQmT74S7MUCPyfeo RE0zxu9u4Yh6Lj1/wJgcWJkpPiRHWb8bPcHs+TYa02sumH0FNcXyRCcCToI/t6P7u3i+ IqZ24aBhdi9BQMY0cg+AFwdHcYOHRCaktHbjSOXbmo15mwqxQtiu/lUrp8hDrD/8SIEf 799ihRQgiN044UFeFUfb9PPxzqMIEgh8oP1EpnMNxyoC927MVKuv7gey6Co2sQvHG2ju Y7qQ== X-Gm-Message-State: AA+aEWZqKOk2Pj8Ff8MrT8DIJ55PXTEo5gtOzSw5QU9CYrrRdOgZxzak GPGBZFSvtsMTcFH5nid9Gw/HVA== X-Received: by 2002:adf:e18d:: with SMTP id k13mr15029376wri.36.1543853001585; Mon, 03 Dec 2018 08:03:21 -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 y185sm6151594wmg.34.2018.12.03.08.03.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Dec 2018 08:03:20 -0800 (PST) Date: Mon, 3 Dec 2018 16:03:18 +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: [PATCH v6 4/4] kdb: Don't back trace on a cpu that didn't round up Message-ID: <20181203160318.35idsm2vb3licod6@holly.lan> References: <20181127173839.34328-1-dianders@chromium.org> <20181127173839.34328-5-dianders@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181127173839.34328-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, Nov 27, 2018 at 09:38:39AM -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 > --- > > 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.rc0.387.gc7a69e6b6c-goog >