V6 [PATCH] sysconf: Add _SC_MINSIGSTKSZ/_SC_SIGSTKSZ [BZ #20305]

H.J. Lu hjl.tools@gmail.com
Tue Oct 20 14:59:01 GMT 2020


On Tue, Oct 20, 2020 at 2:19 AM Dave Martin <Dave.Martin@arm.com> wrote:
>
> On Mon, Oct 19, 2020 at 02:32:35PM -0700, H.J. Lu via Libc-alpha wrote:
> > On Mon, Oct 19, 2020 at 8:08 AM Dave Martin <Dave.Martin@arm.com> wrote:
> > >
> > > On Thu, Oct 15, 2020 at 04:57:28AM -0700, H.J. Lu via Libc-alpha wrote:
>
> [...]
>
> > > > > > diff --git a/sysdeps/unix/sysv/linux/x86/dl-minsigstacksize.h b/sysdeps/unix/sysv/linux/x86/dl-minsigstacksize.h
>
> [...]
>
> > > > > > +/* Emulate AT_MINSIGSTKSZ with XSAVE. */
> > > > > > +
> > > > > > +static inline void
> > > > > > +dl_check_minsigstacksize (void)
> > > > > > +{
> > > > > > +  /* NB: Default to a constant MINSIGSTKSZ.  */
> > > > > > +  _Static_assert (__builtin_constant_p (MINSIGSTKSZ),
> > > > > > +           "MINSIGSTKSZ is constant");
> > > > > > +  /* Return if AT_MINSIGSTKSZ is provide by kernel.  */
> > > > > > +  if (GLRO(dl_minsigstacksize) != MINSIGSTKSZ)
> > > > > > +    return;
> > > > >
> > > > > Couldn't the kernel actually yield MINSIGSTKSZ or a smaller value, say,
> > > > > if running on hardware that doesn't have AVX-512?
> > > > >
> > > > It is OK for MINSIGSTKSZ > AT_MINSIGSTKSZ.  For _SC_SIGSTKSZ_SOURCE,
> > > > dynamic MINSIGSTKSZ is defined as sysconf (_SC_SIGSTKSZ) which is
> > > >
> > > > MAX (SIGSTKSZ, MAX (MINSIGSTKSZ, sysconf (_SC_MINSIGSTKSZ)) * 4)
> > > >
> > > > and dynamic MINSIGSTKSZ is always > MINSIGSTKSZ.
> > > >
> > > > > We might want a separate flag to indicate whether we obtained a value
> > > > > from the auxv, rather relying on MINSIGSTKSZ having this magic meaning.
> > > >
> > > > AT_MINSIGSTKSZ is the only way for GLRO(dl_minsigstacksize) != MINSIGSTKSZ.
> > >
> > > Yes, but reading AT_MINSIGSTKSZ doesn't guarantee that
> > > GLRO(dl_minsigstkszsize) != MINSIGSTKSZ, no?
> > >
> > > What if the value reported for AT_MINSIGSTKSZ is actually the same as
> > > MINSIGSTKSZ?  This could be the case on some arches in future even if
> > > it's never true today.  But the code here assumes that AT_MINSIGSTKSZ
> > > wasn't available in this case, and reverts to a fallback guess.
> >
> > Since the fallback tracks what the kernel does, if AT_MINSIGSTKSZ
> > is 2KB, the fallback will be 2KB or slightly larger.
>
> Well, I guess that should be safe.  It still feels a bit like it works
> by accident, but I may be being too paranoid.

Let me work on that.

>
> Separate question:
>
> How are we going to raise awareness of this issue?  We do want people to
> at least be aware that they should consider migrating.
>
> Ideally _GNU_SOURCE should imply _SC_SIGSTKSZ_SOURCE -- if not now, then
> eventually.  Is this likely to be too disruptive?

I guess so.

> Alternatively we could emit warnings for use of MINSIGSTKSZ and SIGSTKSZ
> even without _SC_SIGSTKSZ_SOURCE, while keeping the old compiletime-
> constant values in this case.

Is there a way to deprecate a constant?


-- 
H.J.


More information about the Libc-alpha mailing list