All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Morse <james.morse@arm.com>
To: Will Deacon <will.deacon@arm.com>, Yang Shi <yang.shi@linaro.org>
Cc: catalin.marinas@arm.com, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linaro-kernel@lists.linaro.org
Subject: Re: [PATCH] arm64: use raw_smp_processor_id in stack backtrace dump
Date: Wed, 10 Feb 2016 11:52:31 +0000	[thread overview]
Message-ID: <56BB247F.6040202@arm.com> (raw)
In-Reply-To: <20160210102939.GD1052@arm.com>

On 10/02/16 10:29, Will Deacon wrote:
> On Tue, Feb 09, 2016 at 01:26:22PM -0800, Yang Shi wrote:
>> dump_backtrace may be called in kthread context, which is not bound to a single
>> cpu, i.e. khungtaskd, then calling smp_processor_id may trigger the below bug
>> report:
> 
> If we're preemptible here, it means that our irq_stack_ptr is potentially
> bogus. Whilst this isn't an issue for kthreads, it does feel like we
> could make this slightly more robust in the face of potential frame
> corruption. Maybe just zero the IRQ stack pointer if we're in preemptible
> context?

Switching between stacks is only valid if we are tracing ourselves while on the
irq_stack, we should probably prevent it for other tasks too.

Something like (untested):
---------------------
if (tsk == current && in_atomic())
	irq_stack_ptr = IRQ_STACK_PTR(smp_processor_id());
else
	irq_stack_ptr = 0;
---------------------

This would work when we trace ourselves while on the irq_stack, but break*
tracing a running task on a remote cpu (khungtaskd doesn't do this).

The same fix would apply to unwind_frame(), we have 'tsk' in both functions.

Thoughts?


James


* If this were to ever happen, we would fail to switch to the original stack if
  tracing a remote irq stack, and print the wrong exception args. I'm not aware
  of any users of this, (panic() sends an IPI).

WARNING: multiple messages have this Message-ID (diff)
From: james.morse@arm.com (James Morse)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm64: use raw_smp_processor_id in stack backtrace dump
Date: Wed, 10 Feb 2016 11:52:31 +0000	[thread overview]
Message-ID: <56BB247F.6040202@arm.com> (raw)
In-Reply-To: <20160210102939.GD1052@arm.com>

On 10/02/16 10:29, Will Deacon wrote:
> On Tue, Feb 09, 2016 at 01:26:22PM -0800, Yang Shi wrote:
>> dump_backtrace may be called in kthread context, which is not bound to a single
>> cpu, i.e. khungtaskd, then calling smp_processor_id may trigger the below bug
>> report:
> 
> If we're preemptible here, it means that our irq_stack_ptr is potentially
> bogus. Whilst this isn't an issue for kthreads, it does feel like we
> could make this slightly more robust in the face of potential frame
> corruption. Maybe just zero the IRQ stack pointer if we're in preemptible
> context?

Switching between stacks is only valid if we are tracing ourselves while on the
irq_stack, we should probably prevent it for other tasks too.

Something like (untested):
---------------------
if (tsk == current && in_atomic())
	irq_stack_ptr = IRQ_STACK_PTR(smp_processor_id());
else
	irq_stack_ptr = 0;
---------------------

This would work when we trace ourselves while on the irq_stack, but break*
tracing a running task on a remote cpu (khungtaskd doesn't do this).

The same fix would apply to unwind_frame(), we have 'tsk' in both functions.

Thoughts?


James


* If this were to ever happen, we would fail to switch to the original stack if
  tracing a remote irq stack, and print the wrong exception args. I'm not aware
  of any users of this, (panic() sends an IPI).

  reply	other threads:[~2016-02-10 11:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-09 21:26 [PATCH] arm64: use raw_smp_processor_id in stack backtrace dump Yang Shi
2016-02-09 21:26 ` Yang Shi
2016-02-10 10:29 ` Will Deacon
2016-02-10 10:29   ` Will Deacon
2016-02-10 11:52   ` James Morse [this message]
2016-02-10 11:52     ` James Morse
2016-02-10 12:10     ` Will Deacon
2016-02-10 12:10       ` Will Deacon
2016-02-10 18:12       ` Shi, Yang
2016-02-10 18:12         ` Shi, Yang
2016-02-11 10:41         ` James Morse
2016-02-11 10:41           ` James Morse
2016-02-11 17:36           ` Shi, Yang
2016-02-11 17:36             ` Shi, Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56BB247F.6040202@arm.com \
    --to=james.morse@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=will.deacon@arm.com \
    --cc=yang.shi@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.