Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1216450 > unrolled thread

Why is irq_stack_union a union?

Started byAndy Lutomirski <luto@amacapital.net>
First post2015-08-31 23:10 +0200
Last post2015-09-01 23:50 +0200
Articles 5 — 2 participants

Back to article view | Back to linux.kernel


Contents

  Why is irq_stack_union a union? Andy Lutomirski <luto@amacapital.net> - 2015-08-31 23:10 +0200
    Re: Why is irq_stack_union a union? Brian Gerst <brgerst@gmail.com> - 2015-08-31 23:50 +0200
      Re: Why is irq_stack_union a union? Andy Lutomirski <luto@amacapital.net> - 2015-09-01 00:10 +0200
        Re: Why is irq_stack_union a union? Brian Gerst <brgerst@gmail.com> - 2015-09-01 06:00 +0200
          Re: Why is irq_stack_union a union? Andy Lutomirski <luto@amacapital.net> - 2015-09-01 23:50 +0200

#1216450 — Why is irq_stack_union a union?

FromAndy Lutomirski <luto@amacapital.net>
Date2015-08-31 23:10 +0200
SubjectWhy is irq_stack_union a union?
Message-ID<q3Ev1-2yp-23@gated-at.bofh.it>
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1216473

FromBrian Gerst <brgerst@gmail.com>
Date2015-08-31 23:50 +0200
Message-ID<q3F7H-3hD-3@gated-at.bofh.it>
In reply to#1216450
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1216480

FromAndy Lutomirski <luto@amacapital.net>
Date2015-09-01 00:10 +0200
Message-ID<q3Fr3-3Tm-9@gated-at.bofh.it>
In reply to#1216473
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1216578

FromBrian Gerst <brgerst@gmail.com>
Date2015-09-01 06:00 +0200
Message-ID<q3KTM-3lU-1@gated-at.bofh.it>
In reply to#1216480
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1217103

FromAndy Lutomirski <luto@amacapital.net>
Date2015-09-01 23:50 +0200
Message-ID<q41Bf-21v-3@gated-at.bofh.it>
In reply to#1216578
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web