From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id 1CCB93857363; Fri, 5 Aug 2022 19:35:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1CCB93857363 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: 159a76a8dd93700cc5a8039e7483836d86974ce2 X-Git-Newrev: 68822420a6da19adf0030ddc836c6968b071b467 Message-Id: <20220805193520.1CCB93857363@sourceware.org> Date: Fri, 5 Aug 2022 19:35:20 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Aug 2022 19:35:20 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=68822420a6da19adf0030ddc836c6968b071b467 commit 68822420a6da19adf0030ddc836c6968b071b467 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)