This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Fix stack memory protection on targets where the stack grows upward
- From: Florian Weimer <fw at deneb dot enyo dot de>
- To: John David Anglin <dave dot anglin at bell dot net>
- Cc: GNU C Library <libc-alpha at sourceware dot org>, Carlos O'Donell <carlos at redhat dot com>, Mike Frysinger <vapier at gentoo dot org>, Aurelien Jarno <aurelien at aurel32 dot net>, Helge Deller <deller at gmx dot de>
- Date: Sun, 16 Apr 2017 23:27:14 +0200
- Subject: Re: [PATCH] Fix stack memory protection on targets where the stack grows upward
- Authentication-results: sourceware.org; auth=none
- References: <AAC3E651-7095-4CCA-BABA-498347523392@bell.net>
* John David Anglin:
> #elif _STACK_GROWS_UP
> - if (mprotect ((char *) pd - pd->guardsize,
> - pd->guardsize - guardsize, prot) != 0)
> + char *new_guard = (char *)(((uintptr_t) pd - guardsize) & ~pagesize_m1);
> + char *old_guard = (char *)(((uintptr_t) pd - pd->guardsize) & ~pagesize_m1);
> + /* The guard size difference might be > 0, but once rounded
> + to the nearest page the size difference might be zero. */
> + if (new_guard > old_guard
> + && mprotect (old_guard, new_guard - old_guard, prot) != 0)
> goto mprot_error;
> #endif
>
This is essentially HPPA-specific code, right? So I guess we can do
whatever it takes there.