* [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
* Re: [PATCH] elf: Use the 64-bit wide 'seen' variable
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
0 siblings, 1 reply; 4+ messages in thread
From: Dmitry V. Levin @ 2021-08-09 0:46 UTC (permalink / raw)
To: Nikita Ermakov; +Cc: libc-alpha
On Sat, Aug 07, 2021 at 05:22:23PM +0300, Nikita Ermakov via Libc-alpha wrote:
> 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.
I agree with the analysis, but I'm not sure uint64_t would be the most
appropriate type in this case. I'd suggest to consider using uintmax_t
instead.
--
ldv
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] elf: Use the 64-bit wide 'seen' variable
2021-08-09 0:46 ` Dmitry V. Levin
@ 2021-08-09 7:48 ` Andreas Schwab
2021-08-17 18:03 ` Nikita Ermakov
0 siblings, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2021-08-09 7:48 UTC (permalink / raw)
To: Dmitry V. Levin; +Cc: Nikita Ermakov, libc-alpha
On Aug 09 2021, Dmitry V. Levin wrote:
> On Sat, Aug 07, 2021 at 05:22:23PM +0300, Nikita Ermakov via Libc-alpha wrote:
>> 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.
>
> I agree with the analysis, but I'm not sure uint64_t would be the most
> appropriate type in this case. I'd suggest to consider using uintmax_t
> instead.
AT_* constants can be arbitrary so no type will fit. The right way to
fix that is to check the range.
Of course, this is only relevant for non-linux configurations.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] elf: Use the 64-bit wide 'seen' variable
2021-08-09 7:48 ` Andreas Schwab
@ 2021-08-17 18:03 ` Nikita Ermakov
0 siblings, 0 replies; 4+ messages in thread
From: Nikita Ermakov @ 2021-08-17 18:03 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Dmitry V. Levin, libc-alpha
Hi Andreas, Dmitry,
Thank you for the comments!
I'm sorry, I was rather busy past week so couldn't reply.
On Mon, Aug 09, 2021 at 09:48:38AM +0200, Andreas Schwab wrote:
> On Aug 09 2021, Dmitry V. Levin wrote:
>
> > On Sat, Aug 07, 2021 at 05:22:23PM +0300, Nikita Ermakov via Libc-alpha wrote:
> >> 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.
> >
> > I agree with the analysis, but I'm not sure uint64_t would be the most
> > appropriate type in this case. I'd suggest to consider using uintmax_t
> > instead.
>
> AT_* constants can be arbitrary so no type will fit. The right way to
> fix that is to check the range.
>
> Of course, this is only relevant for non-linux configurations.
>
So, if AT_* constants can be arbitrary, then we could probably skip all
constants with a value > sizeof(uintmax_t)*8 and process the rest with the uintmax_t variable?
--
Thanks,
Nikita
B8 00 4C CD 21
^ 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).