This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Tests for minimal signal handler functionality in MINSIGSTKSZ space.


On 1/16/19 7:05 AM, Zack Weinberg wrote:
> +xalloc_sigstack (size_t size)
> +{
> +  size_t pagesize = sysconf (_SC_PAGESIZE);
> +  if (pagesize == -1)
> +    FAIL_EXIT1 ("sysconf (_SC_PAGESIZE): %m\n");
> +
> +  size_t stacksize = roundup (size + MINSIGSTKSZ, pagesize);
...
> +  desc->alt_stack.ss_sp    = desc->alloc_base + guardsize;
> +  desc->alt_stack.ss_flags = 0;
> +  desc->alt_stack.ss_size  = stacksize;

While I understand that the actual allocation from the system must round up to
pages, why do you want to round up the amount as seen by ss_{sp,size}?

It seems to me that if you really want to test MINSIGSTKSZ, then you should do
exactly that.  E.g.

  desc->alt_stack.ss_size = size;
  if (_STACK_GROWS_DOWN)
    desc->alt_stack.ss_sp = desc->alloc_base + guardsize;
  else
    desc->alt_stack.ss_sp = desc->alloc_base + guardsize + stacksize - size;


r~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]