From: Luis Machado via Gdb-patches <gdb-patches@sourceware.org>
To: Alan Hayward <Alan.Hayward@arm.com>
Cc: nd <nd@arm.com>,
"gdb-patches\\@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [PATCH] [AArch64] Sanitize the address before working with allocation tags
Date: Thu, 20 May 2021 07:59:54 -0300 [thread overview]
Message-ID: <163b00bd-eb75-6e1d-4840-602b8aceed8b@linaro.org> (raw)
In-Reply-To: <59E75A3D-8F25-4E34-AFF9-1EAD2F51B9FC@arm.com>
On 5/20/21 5:38 AM, Alan Hayward wrote:
>
>
>> On 18 May 2021, at 22:20, Luis Machado via Gdb-patches <gdb-patches@sourceware.org> wrote:
>>
>> On 5/18/21 5:33 PM, Simon Marchi wrote:
>>> On 2021-05-18 4:19 p.m., Luis Machado via Gdb-patches wrote:
>>>> Remove the logical tag/top byte from the address whenever we have to work with
>>>> allocation tags.
>>> Can you explain a bit more why this is needed? What down the line
>>> doesn't like to receive an address with a logical tag?
>>
>> We shouldn't be passing an address with a non-zero top byte (or tag) to a ptrace request, for example. It may work (in fact, it works) but we are not supposed to rely on it. So we sanitize the pointer before it gets to fetch_memtags/store_memtags.
>>
>> This is clarified in the AArch64 Tagged Address ABI document (https://www.kernel.org/doc/html/latest/arm64/tagged-address-abi.html).
>>
>> In an upcoming patch to support memory tags in core files (https://sourceware.org/pipermail/gdb-patches/2021-May/178973.html), this address also gets passed down to the core target's fetch_memtags implementation. It needs to compare addresses, so it doesn't make sense to let through an address with a non-zero top byte, or else we risk not having a match due to differences in the upper byte.
>>
>
>
> Would it make sense to put the address_significant() at the beginning of aarch64_mte_get_atag()?
> That’d ensure any future code that calls aarch64_mte_get_atag() is safe too. And it would mean the higher functions are dealing with a single address throughout.
Yes and no. I didn't want to pollute aarch64_mte_get_atag by passing
gdbarch just to be able to call address_significant. Alternatively, we
could just remove the top byte by hand without using
address_significantm, since we're within the AArch64 target anyway.
>
> Alternatively, it could even move down into target_fetch_memtags() instead (same with target_store_memtags), but I’m less keen on that.
Yes. I considered that, but all the implementations would have to
sanitize the address. We don't know what kinds of targets will want to
implement those functions, so we can't safely assume they want to strip
the top bytes. And, again, we'd need to pass/fetch the gdbarch from
within the native layers just so we can call address_significant.
>
>
> Alan.
>
next prev parent reply other threads:[~2021-05-20 11:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-18 20:19 Luis Machado via Gdb-patches
2021-05-18 20:33 ` Simon Marchi via Gdb-patches
2021-05-18 21:20 ` Luis Machado via Gdb-patches
2021-05-20 8:38 ` Alan Hayward via Gdb-patches
2021-05-20 10:59 ` Luis Machado via Gdb-patches [this message]
2021-05-20 12:22 ` Alan Hayward via Gdb-patches
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=163b00bd-eb75-6e1d-4840-602b8aceed8b@linaro.org \
--to=gdb-patches@sourceware.org \
--cc=Alan.Hayward@arm.com \
--cc=luis.machado@linaro.org \
--cc=nd@arm.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