Thread (72 messages) 72 messages, 9 authors, 2019-06-12

Re: [PATCH v16 16/16] selftests, arm64: add a selftest for passing tagged pointers to kernel

From: Andrey Konovalov <hidden>
Date: 2019-06-12 11:14:43
Also in: amd-gfx, dri-devel, kvm, linux-kselftest, linux-media, linux-mm, linux-rdma, lkml

On Tue, Jun 11, 2019 at 7:50 PM Catalin Marinas [off-list ref] wrote:
On Tue, Jun 11, 2019 at 07:18:04PM +0200, Andrey Konovalov wrote:
quoted
On Tue, Jun 11, 2019 at 5:01 PM Catalin Marinas [off-list ref] wrote:
quoted
static void *tag_ptr(void *ptr)
{
        static int tagged_addr_err = 1;
        unsigned long tag = 0;

        if (tagged_addr_err == 1)
                tagged_addr_err = prctl(PR_SET_TAGGED_ADDR_CTRL,
                                        PR_TAGGED_ADDR_ENABLE, 0, 0, 0);
I think this requires atomics. malloc() can be called from multiple threads.
It's slightly racy but I assume in a real libc it can be initialised
earlier than the hook calls while still in single-threaded mode (I had
a quick attempt with __attribute__((constructor)) but didn't get far).

Even with the race, under normal circumstances calling the prctl() twice
is not a problem. I think the risk here is that someone disables the ABI
via sysctl and the ABI is enabled for some of the threads only.
OK, I'll keep the code racy, but add a comment pointing it out. Thanks!
--
Catalin
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help