public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] elf: Use the 64-bit wide 'seen' variable
@ 2021-08-07 14:22 Nikita Ermakov
  2021-08-09  0:46 ` Dmitry V. Levin
  0 siblings, 1 reply; 4+ messages in thread
From: Nikita Ermakov @ 2021-08-07 14:22 UTC (permalink / raw)
  To: libc-alpha; +Cc: Nikita Ermakov

The 32-bit 'seen' variable doesn't allow to check any auxiliary entry
type with a value greater than 31 as it leads to wrapping and crumbling
of the 'seen' variable.

For example, if AT_UID (which is 11) would precede AT_L1D_CACHEGEOMETRY
(which is 43), then uid would be overridden by an AT_L1D_CACHEGEOMETRY
value.

Using 64-bit wide 'seen' variable allows to handle such situations.

Signed-off-by: Nikita Ermakov <sh1r4s3@mail.si-head.nl>
---
 elf/dl-sysdep.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/elf/dl-sysdep.c b/elf/dl-sysdep.c
index d47bef1340..bb81d3be57 100644
--- a/elf/dl-sysdep.c
+++ b/elf/dl-sysdep.c
@@ -96,12 +96,12 @@ _dl_sysdep_start (void **start_argptr,
 #else
   uid_t uid = 0;
   gid_t gid = 0;
-  unsigned int seen = 0;
+  uint64_t seen = 0;
 # define set_seen_secure() (seen = -1)
 # ifdef HAVE_AUX_XID
 #  define set_seen(tag) (tag)	/* Evaluate for the side effects.  */
 # else
-#  define M(type) (1 << (type))
+#  define M(type) ((uint64_t)1 << (type))
 #  define set_seen(tag) seen |= M ((tag)->a_type)
 # endif
 #endif
-- 
2.32.0


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

end of thread, other threads:[~2021-08-17 18:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-07 14:22 [PATCH] elf: Use the 64-bit wide 'seen' variable Nikita Ermakov
2021-08-09  0:46 ` Dmitry V. Levin
2021-08-09  7:48   ` Andreas Schwab
2021-08-17 18:03     ` Nikita Ermakov

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).