This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] [AArch64 Linux] Get rid of top byte from tagged address
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.
>
> Same with iovec/readv, ioctl, etc., any system call that takes
> a pointer argument.
--
Yao (齐尧)