lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1862775654.72437.1588078588989.JavaMail.zimbra@efficios.com>
Date:   Tue, 28 Apr 2020 08:56:28 -0400 (EDT)
From:   Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
To:     Florian Weimer <fw@...eb.enyo.de>
Cc:     Michael Kerrisk <mtk.manpages@...il.com>,
        libc-alpha <libc-alpha@...rceware.org>,
        carlos <carlos@...hat.com>, Rich Felker <dalias@...c.org>,
        linux-api <linux-api@...r.kernel.org>,
        Boqun Feng <boqun.feng@...il.com>,
        Will Deacon <will.deacon@....com>,
        linux-kernel <linux-kernel@...r.kernel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Ben Maurer <bmaurer@...com>, Dave Watson <davejwatson@...com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Paul <paulmck@...ux.vnet.ibm.com>, Paul Turner <pjt@...gle.com>,
        Joseph Myers <joseph@...esourcery.com>,
        Szabolcs Nagy <szabolcs.nagy@....com>
Subject: Re: [PATCH glibc 5/9] glibc: Perform rseq(2) registration at C
 startup and thread creation (v17)

----- On Apr 28, 2020, at 8:33 AM, Mathieu Desnoyers mathieu.desnoyers@...icios.com wrote:

> ----- On Apr 28, 2020, at 8:02 AM, Florian Weimer fw@...eb.enyo.de wrote:
> 
[...]
>> 
>>> x32 should not be an issue as explained above, so I'm very open to
>>> add this "uptr" for user-space only.
>> 
>> Okay, then please use anonymous unions and structs as necessary, to
>> ensure that the uptr field can be reached on all platforms in the same
>> way.
> 
> OK, will do!

What I came up with looks like this. User-space can use rseq_cs.uptr.ptr
both on 32-bit and 64-bit to update the pointer:

    /* Restartable sequences rseq_cs field.

       Contains NULL when no critical section is active for the current
       thread, or holds a pointer to the currently active struct rseq_cs.

       Updated by user-space, which sets the address of the currently
       active rseq_cs at the beginning of assembly instruction sequence
       block, and set to NULL by the kernel when it restarts an assembly
       instruction sequence block, as well as when the kernel detects that
       it is preempting or delivering a signal outside of the range
       targeted by the rseq_cs.  Also needs to be set to NULL by user-space
       before reclaiming memory that contains the targeted struct rseq_cs.

       Read and set by the kernel.  Set by user-space with single-copy
       atomicity semantics.  This field should only be updated by the
       thread which registered this data structure.  Aligned on 64-bit.

       User-space may perform the update through the rseq_cs.uptr.ptr
       field.  The padding needs to be initialized to zero on 32-bit.  */
    union
      {
        uint64_t ptr64;
#ifdef __LP64__
        uint64_t ptr;
#else   
        struct
          {
# if (defined (__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) || defined (__BIG_ENDIAN)
            uint32_t padding; /* Initialized to zero.  */
            uint32_t ptr32;
# else /* LITTLE */
            uint32_t ptr32;
            uint32_t padding; /* Initialized to zero.  */
# endif /* ENDIAN */
          } ptr;
#endif

#ifndef __KERNEL__
        struct
          {
# ifdef __LP64__
            const struct rseq_cs *ptr;
# else
#  if (defined (__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) || defined (__BIG_ENDIAN)
            uint32_t padding; /* Initialized to zero.  */
            const struct rseq_cs *ptr;
#  else /* LITTLE */
            const struct rseq_cs *ptr;
            uint32_t padding; /* Initialized to zero.  */
#  endif /* ENDIAN */
# endif
          } uptr;
#endif
      } rseq_cs;

Thanks,

Mathieu


-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ