public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
* ARM per-thread stack protector
@ 2013-07-19 16:34 Will Newton
  2013-07-19 21:41 ` Roland McGrath
  0 siblings, 1 reply; 4+ messages in thread
From: Will Newton @ 2013-07-19 16:34 UTC (permalink / raw)
  To: libc-ports

Hi all,

I've been looking into implementing pre-thread stack protector
canaries for ARM and I would be interested in people's opinions on
whether I have understood it correctly.

At the moment the global canary value is stored in __stack_chk_guard
which is exported by glibc and accesses to this variable are emitted
by gcc if it detects a capable glibc version at configure time.

glibc with per-thread stack canary values does not export
__stack_chk_guard but adds an element to the TCB to contain the
per-thread value and gcc emits TP-relative accesses to load this
value.

Implementing the per-thread scheme would therefore seem to me to break
ABI compatibility and cause problems when mixing gcc and glibc
versions:

Old gcc, old glibc: OK
Old gcc, new glibc: __stack_chk_guard is missing, link time failure.
New gcc, old glibc: stack canary value is loaded from uninitialized
TCB area, security issue.
New gcc, new glibc: OK.

It should be possible to add support for both schemes at the same time
in glibc, exporting __stack_chk_guard at the same time as supporting
per-thread canary values, which would fix the "old gcc, new glibc"
case.

I am not sure if there is a good fix for "new gcc, old glibc",
although gcc configure could be taught about glibc versions and do the
right thing for each.

Or is there a simpler way to handle this? Has any other architecture
implemented per-thread stack protector after already supporting the
simpler scheme?

Thanks,

--
Will Newton
Toolchain Working Group, Linaro

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

* Re: ARM per-thread stack protector
  2013-07-19 16:34 ARM per-thread stack protector Will Newton
@ 2013-07-19 21:41 ` Roland McGrath
  2013-07-22  9:15   ` Will Newton
  0 siblings, 1 reply; 4+ messages in thread
From: Roland McGrath @ 2013-07-19 21:41 UTC (permalink / raw)
  To: Will Newton; +Cc: libc-ports

No machine has a per-thread canary value.  Using one would break
user-implemented stack-switching schemes.

Some machines store the global canary value in every thread's TCB for the
sole reason that it's cheaper to access a field in the TCB than to access a
global variable.  I don't think that's the case on ARM.

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

* Re: ARM per-thread stack protector
  2013-07-19 21:41 ` Roland McGrath
@ 2013-07-22  9:15   ` Will Newton
  2013-07-22 22:01     ` Roland McGrath
  0 siblings, 1 reply; 4+ messages in thread
From: Will Newton @ 2013-07-22  9:15 UTC (permalink / raw)
  To: Roland McGrath; +Cc: libc-ports

On 19 July 2013 22:41, Roland McGrath <roland@hack.frob.com> wrote:

Hi Roland,

> No machine has a per-thread canary value.  Using one would break
> user-implemented stack-switching schemes.
>
> Some machines store the global canary value in every thread's TCB for the
> sole reason that it's cheaper to access a field in the TCB than to access a
> global variable.  I don't think that's the case on ARM.

Thanks for the clarification. So the two methods are functionally identical?

I looked at this problem initially after reading Carlos's mail to the
fedora devel list:

http://www.mail-archive.com/devel@lists.fedoraproject.org/msg62354.html

From what I understand then all that is missing on ARM from that list
is pointer mangling support?

Thanks,

--
Will Newton
Toolchain Working Group, Linaro

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

* Re: ARM per-thread stack protector
  2013-07-22  9:15   ` Will Newton
@ 2013-07-22 22:01     ` Roland McGrath
  0 siblings, 0 replies; 4+ messages in thread
From: Roland McGrath @ 2013-07-22 22:01 UTC (permalink / raw)
  To: Will Newton; +Cc: libc-ports

> Thanks for the clarification. So the two methods are functionally identical?

Yes.  Where you keep the value is just a matter of optimal implementation
convenience for the particular machine.

> >From what I understand then all that is missing on ARM from that list
> is pointer mangling support?

I have no new information.

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

end of thread, other threads:[~2013-07-22 22:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-19 16:34 ARM per-thread stack protector Will Newton
2013-07-19 21:41 ` Roland McGrath
2013-07-22  9:15   ` Will Newton
2013-07-22 22:01     ` Roland McGrath

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 read-only IMAP folder(s) and NNTP newsgroup(s).