From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id 291B0383FBB4; Wed, 26 Oct 2022 15:18:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 291B0383FBB4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666797491; bh=axodbxC6IttNO9SypzBjbcaAlN2yzjLcT7HIAsRwo0c=; h=From:To:Subject:Date:From; b=gwil9H+71edfkqociZrIo83ER7sPEoQcEx1D7T08EpoflgF4lZqxxDn0kyTO1efJ6 FU0jK6dcckWeUKTjB9sZepeM5q6GZWGQ3PsMh3PPD2M6dwsEGveXXj0PhVkMx9Rvio zvHHgxUAltUMSEcj602DkLsftIRIJvB2cXqhvBb8= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Szabolcs Nagy To: glibc-cvs@sourceware.org Subject: [glibc/arm/morello/main] cheri: fix pointer tagging in tsearch X-Act-Checkin: glibc X-Git-Author: Szabolcs Nagy X-Git-Refname: refs/heads/arm/morello/main X-Git-Oldrev: 5e3c7df415a06e99191afc0fe47514821d969567 X-Git-Newrev: ba60f2ef0c3a20ca3cc68aeb63d7d7f220b81ece Message-Id: <20221026151811.291B0383FBB4@sourceware.org> Date: Wed, 26 Oct 2022 15:18:11 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=ba60f2ef0c3a20ca3cc68aeb63d7d7f220b81ece commit ba60f2ef0c3a20ca3cc68aeb63d7d7f220b81ece Author: Szabolcs Nagy Date: Mon Jul 12 11:11:05 2021 +0100 cheri: fix pointer tagging in tsearch USE_MALLOC_LOW_BIT should work for capabilities too, but we need to ensure that pointer provenance is right: the red/black flag is computed as uintptr_t, but with uintptr_t | uintptr_t it's not clear which side provides the provenance. So use unsigned int type for the flag (which is the type used in case of !USE_MALLOC_LOW_BIT anyway), then unsigned int | uintptr_t works. The type of RED is corrected too to match unsigned int. Diff: --- misc/tsearch.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/misc/tsearch.c b/misc/tsearch.c index 852cadf7b9..1787cf4991 100644 --- a/misc/tsearch.c +++ b/misc/tsearch.c @@ -131,15 +131,15 @@ typedef struct node_t uintptr_t right_node; } *node; -#define RED(N) (node)((N)->left_node & ((uintptr_t) 0x1)) +#define RED(N) (unsigned int)((N)->left_node & ((uintptr_t) 0x1)) #define SETRED(N) (N)->left_node |= ((uintptr_t) 0x1) #define SETBLACK(N) (N)->left_node &= ~((uintptr_t) 0x1) -#define SETNODEPTR(NP,P) (*NP) = (node)((((uintptr_t)(*NP)) \ +#define SETNODEPTR(NP,P) (*NP) = (node)((unsigned int)(((uintptr_t)(*NP)) \ & (uintptr_t) 0x1) | (uintptr_t)(P)) #define LEFT(N) (node)((N)->left_node & ~((uintptr_t) 0x1)) #define LEFTPTR(N) (node *)(&(N)->left_node) -#define SETLEFT(N,L) (N)->left_node = (((N)->left_node & (uintptr_t) 0x1) \ - | (uintptr_t)(L)) +#define SETLEFT(N,L) (N)->left_node = ((unsigned int)((N)->left_node \ + & (uintptr_t) 0x1) | (uintptr_t)(L)) #define RIGHT(N) (node)((N)->right_node) #define RIGHTPTR(N) (node *)(&(N)->right_node) #define SETRIGHT(N,R) (N)->right_node = (uintptr_t)(R)