From: "H.J. Lu" <hjl.tools@gmail.com>
To: Szabolcs Nagy <szabolcs.nagy@arm.com>
Cc: Florian Weimer <fweimer@redhat.com>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
"Shanbhogue, Vedvyas" <vedvyas.shanbhogue@intel.com>,
"H.J. Lu via Libc-alpha" <libc-alpha@sourceware.org>,
Joseph Myers <joseph@codesourcery.com>
Subject: Re: [RFC] <sys/tagged-address.h>: An API for tagged address
Date: Mon, 22 Feb 2021 05:57:48 -0800 [thread overview]
Message-ID: <CAMe9rOprpmAuq3_1S6ixKFJMJo7iss0-=yGiwaabQUf16dC7JA@mail.gmail.com> (raw)
In-Reply-To: <20210222082723.GH12795@arm.com>
On Mon, Feb 22, 2021 at 12:28 AM Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
>
> The 02/18/2021 14:32, H.J. Lu wrote:
> >
> > We are working to enable LAM in glibc and GCC (HWASAN).
> >
> > 0. LAM is disabled when the process starts.
> > 1. Define GNU property markers for LAM compatibility.
> > 2. Update ld.so to support LAM.
> > 3. Make libc.so LAM compatible (memmove).
>
> if pointers to the same object always have the same tag,
> then memmove should work without changes i think.
string/memmove.c has
/* This test makes the forward copying code be used whenever possible.
Reduces the working set. */
if (dstp - srcp >= len) /* *Unsigned* compare! */
This doesn't work when pointers have tags.
char *
inhibit_loop_to_libcall
simple_memmove (char *dst, const char *src, size_t n)
{
char *ret = dst;
if (src < dst)
{
dst += n;
src += n;
while (n--)
*--dst = *--src;
}
else
while (n--)
*dst++ = *src++;
return ret;
}
has the same issue.
> if such pointers can have different tags then all pointer
> comparisions are problematic, not just memmove.
We haven't found other pointer usages in glibc which are
incompatible with tags.
> > 4. Provide an API to enable LAM.
> >
> > We noticed a few issues:
> >
> > 1. HWASAN should use the glibc API to enable tagged address
> > since glibc must track the tagged address mask.
>
> how does that mask work?
> is it possible to set it to different values or just on/off?
It is a bit mask of uintptr_t. The default is (uintptr_t) -1.
#ifdef __GNUC__
/* A mask for constant address BITS used in address translation. */
# define TAGGED_ADDRESS_MASK(BITS) \
(__extension__ \
({ \
_Static_assert (TAGGED_ADDRESS_VALID_BITS (BITS), \
"Tagged address bits must be valid"); \
(((uintptr_t) 1) << (BITS)) - 1; \
}))
#endif
> > 2. set_tagged_address_mask shouldn't be allowed after
> > pthread_create is called.
>
> such api breaks software composability.
> i don't have a good solution (other than libc doing an early
> decision on its own).
How does it work with HWASAN?
> > 3. After set_tagged_address_mask is called, can it be called
> > again to change tagged address mask.
>
> after tagged pointers escape it is unlikely that changing
> settings works.
>
--
H.J.
next prev parent reply other threads:[~2021-02-22 13:58 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-11 17:37 H.J. Lu
2021-02-11 20:28 ` Joseph Myers
2021-02-11 21:39 ` H.J. Lu
2021-02-12 9:43 ` Florian Weimer
2021-02-12 13:06 ` H.J. Lu
2021-02-17 18:43 ` H.J. Lu
2021-02-17 21:58 ` H.J. Lu
2021-02-18 13:24 ` Szabolcs Nagy
2021-02-18 13:28 ` Florian Weimer
2021-02-18 13:50 ` Szabolcs Nagy
2021-02-18 22:32 ` H.J. Lu
2021-02-22 8:27 ` Szabolcs Nagy
2021-02-22 13:57 ` H.J. Lu [this message]
2021-02-18 13:17 ` Szabolcs Nagy
2021-02-18 13:21 ` Florian Weimer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAMe9rOprpmAuq3_1S6ixKFJMJo7iss0-=yGiwaabQUf16dC7JA@mail.gmail.com' \
--to=hjl.tools@gmail.com \
--cc=fweimer@redhat.com \
--cc=joseph@codesourcery.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=libc-alpha@sourceware.org \
--cc=szabolcs.nagy@arm.com \
--cc=vedvyas.shanbhogue@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).