Re: [PATCH] [AArch64 Linux] Get rid of top byte from tagged address

Pedro Alves
2017-10-19T13:22:54Z

On 10/19/2017 02:17 PM, Yao Qi wrote:
> Pedro Alves <palves@redhat.com> writes:
>
>> This means with something like:
>>
>> #define tagptr(PTR) \
>> ((typeof (PTR)) ((uintptr_t) (PTR) | 0xf000000000000000ULL))
>>
>> strcat (buf, "hello\n");
>>
>> char *ptr = tagptr(buf); // assume this is hidden from view.
>>
>> write (1, ptr, 6); // kernel rejects this.
>>
>
> Right, it returns -1, and errno is EFAULT.
>
>> and then the user might be puzzled because stepping through
>> that code:
>>
>> (gdb) print ptr
>> (gdb) print ptr[0]
>>
>> etc. works without error.
>
> That is right/expected to me, because in the c code, we can still access
> ptr[0] without any error, like "char c = ptr[0]", so it is reasonable
> that we can access them in GDB. Kernel rejects that address, doesn't
> mean we can't access that address.

OK, that's reasonable.

Thanks,
Pedro Alves