public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/arm/morello/main] cheri: fix pointer tagging in tsearch
@ 2022-10-26 15:18 Szabolcs Nagy
  0 siblings, 0 replies; 4+ messages in thread
From: Szabolcs Nagy @ 2022-10-26 15:18 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=ba60f2ef0c3a20ca3cc68aeb63d7d7f220b81ece

commit ba60f2ef0c3a20ca3cc68aeb63d7d7f220b81ece
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
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)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [glibc/arm/morello/main] cheri: fix pointer tagging in tsearch
@ 2022-11-23 14:46 Szabolcs Nagy
  0 siblings, 0 replies; 4+ messages in thread
From: Szabolcs Nagy @ 2022-11-23 14:46 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c0ba8ad1fe451f2849ce7c6fdb477c94471d5d25

commit c0ba8ad1fe451f2849ce7c6fdb477c94471d5d25
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
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)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [glibc/arm/morello/main] cheri: fix pointer tagging in tsearch
@ 2022-10-27 13:56 Szabolcs Nagy
  0 siblings, 0 replies; 4+ messages in thread
From: Szabolcs Nagy @ 2022-10-27 13:56 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=6de52d57a1dd1f85ccd9bdbb3c5231e36dd00a99

commit 6de52d57a1dd1f85ccd9bdbb3c5231e36dd00a99
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
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)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [glibc/arm/morello/main] cheri: fix pointer tagging in tsearch
@ 2022-08-05 19:35 Szabolcs Nagy
  0 siblings, 0 replies; 4+ messages in thread
From: Szabolcs Nagy @ 2022-08-05 19:35 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=68822420a6da19adf0030ddc836c6968b071b467

commit 68822420a6da19adf0030ddc836c6968b071b467
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
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)


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-11-23 14:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-26 15:18 [glibc/arm/morello/main] cheri: fix pointer tagging in tsearch Szabolcs Nagy
  -- strict thread matches above, loose matches on Subject: below --
2022-11-23 14:46 Szabolcs Nagy
2022-10-27 13:56 Szabolcs Nagy
2022-08-05 19:35 Szabolcs Nagy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).