linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Andy Lutomirski <luto@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>, X86 ML <x86@kernel.org>,
	Borislav Petkov <bpetkov@suse.de>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Brian Gerst <brgerst@gmail.com>,
	Dave Hansen <dave.hansen@intel.com>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH] x86/orc: Don't bail on stack overflow
Date: Sat, 25 Nov 2017 22:41:15 -0600	[thread overview]
Message-ID: <20171126044115.tper4nvt47tsxr2j@treble> (raw)
In-Reply-To: <CALCETrVB4gObe0SdjYaeK=KfzVMcNa+kCaN=Rn9GHpkKQ+S3JQ@mail.gmail.com>

On Sat, Nov 25, 2017 at 08:25:12PM -0800, Andy Lutomirski wrote:
> On Sat, Nov 25, 2017 at 6:40 PM, Josh Poimboeuf <jpoimboe@redhat.com> wrote:
> > On Sat, Nov 25, 2017 at 04:16:23PM -0800, Andy Lutomirski wrote:
> >> Can you send me whatever config and exact commit hash generated this?
> >> I can try to figure out why it failed.
> >
> > Sorry, I've been traveling.  I just got some time to take a look at
> > this.  I think there are at least two unwinder issues here:
> >
> > - It doesn't deal gracefully with the case where the stack overflows and
> >   the stack pointer itself isn't on a valid stack but the
> >   to-be-dereferenced data *is*.
> >
> > - The oops dump code doesn't know how to print partial pt_regs, for the
> >   case where if we get an interrupt/exception in *early* entry code
> >   before the full pt_regs have been saved.
> >
> > (Andy, I'm not quite sure about your patch, and whether it's still
> > needed after these patches.  I'll need to look at it later when I have
> > more time.)
> 
> I haven't tested yet, but I think my patch is probably still needed.
> The issue I fixed is that unwind_start() would bail out early if sp
> was below the stack.  Also:

Makes sense, maybe both are needed.  Your patch deals with a bad SP at
the beginning and mine deals with a bad SP in the middle.

> > -static bool stack_access_ok(struct unwind_state *state, unsigned long addr,
> > +static bool stack_access_ok(struct unwind_state *state, unsigned long _addr,
> >                             size_t len)
> >  {
> >         struct stack_info *info = &state->stack_info;
> > +       void *addr = (void *)_addr;
> >
> > -       /*
> > -        * If the address isn't on the current stack, switch to the next one.
> > -        *
> > -        * We may have to traverse multiple stacks to deal with the possibility
> > -        * that info->next_sp could point to an empty stack and the address
> > -        * could be on a subsequent stack.
> > -        */
> > -       while (!on_stack(info, (void *)addr, len))
> > -               if (get_stack_info(info->next_sp, state->task, info,
> > -                                  &state->stack_mask))
> > -                       return false;
> > +       if (!on_stack(info, addr, len) &&
> > +           (get_stack_info(addr, state->task, info, &state->stack_mask)))
> > +               return false;
> >
> >         return true;
> >  }
> 
> This looks odd to me before and after.  Shouldn't this be side-effect
> free?  That is, shouldn't it create a copy of info and stack_mask and
> point that to get_stack_info() rather than allowing get_stack_info()
> to modify the unwind state?

I think the side effects are ok, but maybe stack_access_ok() should be
renamed to make it clearer that it has side effects.

-- 
Josh

  reply	other threads:[~2017-11-26  4:41 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-25 17:28 [PATCH] x86/orc: Don't bail on stack overflow Andy Lutomirski
2017-11-25 18:26 ` Andy Lutomirski
2017-11-25 23:13   ` Thomas Gleixner
2017-11-26  0:16     ` Andy Lutomirski
2017-11-26  2:40       ` Josh Poimboeuf
2017-11-26  4:25         ` Andy Lutomirski
2017-11-26  4:41           ` Josh Poimboeuf [this message]
2017-11-26  4:48             ` Josh Poimboeuf
2017-11-26  9:27               ` Thomas Gleixner
2017-11-27  9:38         ` Ingo Molnar
2017-11-27  9:49           ` Ingo Molnar
2017-11-27 12:45           ` Josh Poimboeuf
2017-11-27 13:13             ` Ingo Molnar

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=20171126044115.tper4nvt47tsxr2j@treble \
    --to=jpoimboe@redhat.com \
    --cc=bpetkov@suse.de \
    --cc=brgerst@gmail.com \
    --cc=dave.hansen@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=x86@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).