From patchwork Wed Sep 10 14:44:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 37210 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f71.google.com (mail-pa0-f71.google.com [209.85.220.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BBEB320293 for ; Wed, 10 Sep 2014 14:44:56 +0000 (UTC) Received: by mail-pa0-f71.google.com with SMTP id rd3sf35553001pab.10 for ; Wed, 10 Sep 2014 07:44:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=yYwlX4aRozVQNXAFexlb8MTQdccshD2N5u3Y3FRYbw8=; b=R/zl+V+zKvskK3mCQADmY/s7gsSAOahepBbRvipa5pqLdNP2qVFJhdrlHZnKGjmc0u WdnDbHrLlcC/7+TJ/huCL2aFtNXjZ3g6IB7sRu8w1+WBGwcVBpLYpmRCbkVh2f1Jgf1e VOOT0xbmOPwOLrXz6Bl48Ypz2tUTgwgv0XE3l+rpdZXmuG02f3P5h61qc50q2vKciaP9 LbNvyaa/5A/lPKjcKPAnJrtWpHFWTPh71jZF2VvA5qN7Z7rQ6J9i2h9I3zASDjgp+q0t Nt7kmBxqDb9aDviKPOqB4uJQE/g9AZB79QCczAuseDBT0M78kQECBYtkD/p6PD7e5XxH tOtQ== X-Gm-Message-State: ALoCoQmZctGOeX4jeYO7TlxD5wpFjwZG9ZxEMD3eQnQOCZzAIP/FuyiMoUx7wcqxcY9Anbl8YB8B X-Received: by 10.66.249.197 with SMTP id yw5mr12393824pac.34.1410360296075; Wed, 10 Sep 2014 07:44:56 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.42.16 with SMTP id b16ls1154425qga.16.gmail; Wed, 10 Sep 2014 07:44:55 -0700 (PDT) X-Received: by 10.221.48.201 with SMTP id ux9mr871061vcb.68.1410360295940; Wed, 10 Sep 2014 07:44:55 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id c11si6949279vdj.97.2014.09.10.07.44.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 10 Sep 2014 07:44:55 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id le20so4645315vcb.13 for ; Wed, 10 Sep 2014 07:44:55 -0700 (PDT) X-Received: by 10.220.97.5 with SMTP id j5mr36851682vcn.16.1410360295857; Wed, 10 Sep 2014 07:44:55 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp448202vcb; Wed, 10 Sep 2014 07:44:55 -0700 (PDT) X-Received: by 10.180.20.148 with SMTP id n20mr474580wie.22.1410360294914; Wed, 10 Sep 2014 07:44:54 -0700 (PDT) Received: from mail-wg0-f42.google.com (mail-wg0-f42.google.com [74.125.82.42]) by mx.google.com with ESMTPS id kn9si6326415wjb.140.2014.09.10.07.44.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 10 Sep 2014 07:44:54 -0700 (PDT) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 74.125.82.42 as permitted sender) client-ip=74.125.82.42; Received: by mail-wg0-f42.google.com with SMTP id x12so6254175wgg.25 for ; Wed, 10 Sep 2014 07:44:54 -0700 (PDT) X-Received: by 10.180.39.140 with SMTP id p12mr435293wik.40.1410360294490; Wed, 10 Sep 2014 07:44:54 -0700 (PDT) Received: from sundance.lan (cpc4-aztw19-0-0-cust157.18-1.cable.virginm.net. [82.33.25.158]) by mx.google.com with ESMTPSA id cz3sm18826114wjb.23.2014.09.10.07.44.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Sep 2014 07:44:53 -0700 (PDT) From: Daniel Thompson To: Steven Rostedt , Ingo Molnar Cc: Daniel Thompson , linux-kernel@vger.kernel.org, patches@linaro.org, linaro-kernel@lists.linaro.org, John Stultz , Sumit Semwal , Jason Wessel Subject: [PATCH 3.17-rc4] trace: kdb: Fix kernel panic during ftdump Date: Wed, 10 Sep 2014 15:44:07 +0100 Message-Id: <1410360247-13791-1-git-send-email-daniel.thompson@linaro.org> X-Mailer: git-send-email 1.9.3 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: daniel.thompson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Currently kdb's ftdump command unconditionally crashes due to a null pointer de-reference whenever the command is run. This in turn causes the kernel to panic. The abridged stacktrace (gathered with ARCH=arm) is: --- cut here --- [] (panic) from [] (die+0x264/0x440) [] (die) from [] (__do_kernel_fault.part.11+0x74/0x84) [] (__do_kernel_fault.part.11) from [] (do_page_fault+0x1d0/0x3c4) [] (do_page_fault) from [] (do_DataAbort+0x48/0xac) [] (do_DataAbort) from [] (__dabt_svc+0x38/0x60) Exception stack(0xc0deba88 to 0xc0debad0) ba80: e8c29180 00000001 e9854304 e9854300 c0f567d8 c0df2580 baa0: 00000000 00000000 00000000 c0f117b8 c0e3a3c0 c0debb0c 00000000 c0debad0 bac0: 0000672e c02f4d60 60000193 ffffffff [] (__dabt_svc) from [] (kdb_ftdump+0x1e4/0x3d8) [] (kdb_ftdump) from [] (kdb_parse+0x2b8/0x698) [] (kdb_parse) from [] (kdb_main_loop+0x52c/0x784) [] (kdb_main_loop) from [] (kdb_stub+0x238/0x490) --- cut here --- The NULL deref occurs due to the initialized use of struct trace_iter's buffer_iter member. This patch solves this by providing a collection of ring_buffer_iter(s) and using this to initialized buffer_iter. Note that static allocation is used solely because the trace_iter itself is also static allocated. Signed-off-by: Daniel Thompson Cc: Jason Wessel Cc: Steven Rostedt Cc: Ingo Molnar --- kernel/trace/trace_kdb.c | 2 ++ 1 file changed, 2 insertions(+) -- 1.9.3 diff --git a/kernel/trace/trace_kdb.c b/kernel/trace/trace_kdb.c index bd90e1b..989288a 100644 --- a/kernel/trace/trace_kdb.c +++ b/kernel/trace/trace_kdb.c @@ -20,10 +20,12 @@ static void ftrace_dump_buf(int skip_lines, long cpu_file) { /* use static because iter can be a bit big for the stack */ static struct trace_iterator iter; + static struct ring_buffer_iter *buffer_iter[CONFIG_NR_CPUS]; unsigned int old_userobj; int cnt = 0, cpu; trace_init_global_iter(&iter); + iter.buffer_iter = buffer_iter; for_each_tracing_cpu(cpu) { atomic_inc(&per_cpu_ptr(iter.trace_buffer->data, cpu)->disabled);