All of lore.kernel.org
 help / color / mirror / Atom feed
* Why is irq_stack_union a union?
@ 2015-08-31 21:00 Andy Lutomirski
  2015-08-31 21:47 ` Brian Gerst
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Lutomirski @ 2015-08-31 21:00 UTC (permalink / raw)
  To: Brian Gerst, linux-kernel, X86 ML; +Cc: Steven Rostedt, Andi Kleen

Why not just a struct?

Also, why is this all tangled up in gsbase initialization?  And why
does irq_stack_ptr point 64 bytes from the top?  And why does the
stack overflow thing look STACK_TOP_MARGIN == 128 bytes from the top?

Confused.

--Andy

-- 
Andy Lutomirski
AMA Capital Management, LLC

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Why is irq_stack_union a union?
  2015-08-31 21:00 Why is irq_stack_union a union? Andy Lutomirski
@ 2015-08-31 21:47 ` Brian Gerst
  2015-08-31 22:01   ` Andy Lutomirski
  0 siblings, 1 reply; 5+ messages in thread
From: Brian Gerst @ 2015-08-31 21:47 UTC (permalink / raw)
  To: Andy Lutomirski; +Cc: linux-kernel, X86 ML, Steven Rostedt, Andi Kleen

On Mon, Aug 31, 2015 at 5:00 PM, Andy Lutomirski <luto@amacapital.net> wrote:
> Why not just a struct? Also, why is this all tangled up in gsbase initialization?

It has to do with the fact that the GCC stackprotector is hardcoded to
look for the canary at %gs:40.  Since we also use %gs for the percpu
segment, we have to make sure that the canary is placed at the start
of the percpu section.  Overlaying it onto the bottom of the IRQ stack
and was the most convenient way to do it, with a side benefit that
overflowing the stack will trip the canary.

--
Brian Gerst

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Why is irq_stack_union a union?
  2015-08-31 21:47 ` Brian Gerst
@ 2015-08-31 22:01   ` Andy Lutomirski
  2015-09-01  3:55     ` Brian Gerst
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Lutomirski @ 2015-08-31 22:01 UTC (permalink / raw)
  To: Brian Gerst; +Cc: linux-kernel, X86 ML, Steven Rostedt, Andi Kleen

On Mon, Aug 31, 2015 at 2:47 PM, Brian Gerst <brgerst@gmail.com> wrote:
> On Mon, Aug 31, 2015 at 5:00 PM, Andy Lutomirski <luto@amacapital.net> wrote:
>> Why not just a struct? Also, why is this all tangled up in gsbase initialization?
>
> It has to do with the fact that the GCC stackprotector is hardcoded to
> look for the canary at %gs:40.  Since we also use %gs for the percpu
> segment, we have to make sure that the canary is placed at the start
> of the percpu section.  Overlaying it onto the bottom of the IRQ stack
> and was the most convenient way to do it, with a side benefit that
> overflowing the stack will trip the canary.

Would a struct not make more sense, then?

--Andy

>
> --
> Brian Gerst



-- 
Andy Lutomirski
AMA Capital Management, LLC

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Why is irq_stack_union a union?
  2015-08-31 22:01   ` Andy Lutomirski
@ 2015-09-01  3:55     ` Brian Gerst
  2015-09-01 21:42       ` Andy Lutomirski
  0 siblings, 1 reply; 5+ messages in thread
From: Brian Gerst @ 2015-09-01  3:55 UTC (permalink / raw)
  To: Andy Lutomirski; +Cc: linux-kernel, X86 ML, Steven Rostedt, Andi Kleen

On Mon, Aug 31, 2015 at 6:01 PM, Andy Lutomirski <luto@amacapital.net> wrote:
> On Mon, Aug 31, 2015 at 2:47 PM, Brian Gerst <brgerst@gmail.com> wrote:
>> On Mon, Aug 31, 2015 at 5:00 PM, Andy Lutomirski <luto@amacapital.net> wrote:
>>> Why not just a struct? Also, why is this all tangled up in gsbase initialization?
>>
>> It has to do with the fact that the GCC stackprotector is hardcoded to
>> look for the canary at %gs:40.  Since we also use %gs for the percpu
>> segment, we have to make sure that the canary is placed at the start
>> of the percpu section.  Overlaying it onto the bottom of the IRQ stack
>> and was the most convenient way to do it, with a side benefit that
>> overflowing the stack will trip the canary.
>
> Would a struct not make more sense, then?

Why would it?  A union shows the overlay better.

--
Brian Gerst

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Why is irq_stack_union a union?
  2015-09-01  3:55     ` Brian Gerst
@ 2015-09-01 21:42       ` Andy Lutomirski
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Lutomirski @ 2015-09-01 21:42 UTC (permalink / raw)
  To: Brian Gerst; +Cc: linux-kernel, X86 ML, Steven Rostedt, Andi Kleen

On Mon, Aug 31, 2015 at 8:55 PM, Brian Gerst <brgerst@gmail.com> wrote:
> On Mon, Aug 31, 2015 at 6:01 PM, Andy Lutomirski <luto@amacapital.net> wrote:
>> On Mon, Aug 31, 2015 at 2:47 PM, Brian Gerst <brgerst@gmail.com> wrote:
>>> On Mon, Aug 31, 2015 at 5:00 PM, Andy Lutomirski <luto@amacapital.net> wrote:
>>>> Why not just a struct? Also, why is this all tangled up in gsbase initialization?
>>>
>>> It has to do with the fact that the GCC stackprotector is hardcoded to
>>> look for the canary at %gs:40.  Since we also use %gs for the percpu
>>> segment, we have to make sure that the canary is placed at the start
>>> of the percpu section.  Overlaying it onto the bottom of the IRQ stack
>>> and was the most convenient way to do it, with a side benefit that
>>> overflowing the stack will trip the canary.
>>
>> Would a struct not make more sense, then?
>
> Why would it?  A union shows the overlay better.

I guess you're thinking of it as an overlay and I'm thinking of it as
the layout being the IRQ stack directly above the stack canary.

--Andy

>
> --
> Brian Gerst



-- 
Andy Lutomirski
AMA Capital Management, LLC

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-09-01 21:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-31 21:00 Why is irq_stack_union a union? Andy Lutomirski
2015-08-31 21:47 ` Brian Gerst
2015-08-31 22:01   ` Andy Lutomirski
2015-09-01  3:55     ` Brian Gerst
2015-09-01 21:42       ` Andy Lutomirski

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.