* [PATCH] getauxval: fix crash on systems without HAVE_AUX_VECTOR
@ 2016-04-02 10:57 Samuel Thibault
2016-04-02 17:30 ` Mike Frysinger
2016-04-11 7:55 ` Markus Trippelsdorf
0 siblings, 2 replies; 5+ messages in thread
From: Samuel Thibault @ 2016-04-02 10:57 UTC (permalink / raw)
To: GNU C Library; +Cc: bug-hurd
Systems without HAVE_AUX_VECTOR have GLRO(dl_auxv) == NULL, and
getauxval would thus crash.
* misc/getauxval.c (__getauxval): Check for GLRO(dl_auxv) != NULL before
looping through the list.
diff --git a/misc/getauxval.c b/misc/getauxval.c
index e48f40f..7ba0598 100644
--- a/misc/getauxval.c
+++ b/misc/getauxval.c
@@ -30,9 +30,10 @@ __getauxval (unsigned long int type)
else if (type == AT_HWCAP2)
return GLRO(dl_hwcap2);
- for (p = GLRO(dl_auxv); p->a_type != AT_NULL; p++)
- if (p->a_type == type)
- return p->a_un.a_val;
+ if (GLRO(dl_auxv) != NULL)
+ for (p = GLRO(dl_auxv); p->a_type != AT_NULL; p++)
+ if (p->a_type == type)
+ return p->a_un.a_val;
__set_errno (ENOENT);
return 0;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] getauxval: fix crash on systems without HAVE_AUX_VECTOR
2016-04-02 10:57 [PATCH] getauxval: fix crash on systems without HAVE_AUX_VECTOR Samuel Thibault
@ 2016-04-02 17:30 ` Mike Frysinger
2016-04-04 19:38 ` Roland McGrath
2016-04-11 7:55 ` Markus Trippelsdorf
1 sibling, 1 reply; 5+ messages in thread
From: Mike Frysinger @ 2016-04-02 17:30 UTC (permalink / raw)
To: GNU C Library, bug-hurd
[-- Attachment #1: Type: text/plain, Size: 1050 bytes --]
On 02 Apr 2016 12:57, Samuel Thibault wrote:
> Systems without HAVE_AUX_VECTOR have GLRO(dl_auxv) == NULL, and
> getauxval would thus crash.
assuming this is for GNU/hurd
> --- a/misc/getauxval.c
> +++ b/misc/getauxval.c
> @@ -30,9 +30,10 @@ __getauxval (unsigned long int type)
> else if (type == AT_HWCAP2)
> return GLRO(dl_hwcap2);
>
> - for (p = GLRO(dl_auxv); p->a_type != AT_NULL; p++)
> - if (p->a_type == type)
> - return p->a_un.a_val;
> + if (GLRO(dl_auxv) != NULL)
> + for (p = GLRO(dl_auxv); p->a_type != AT_NULL; p++)
> + if (p->a_type == type)
> + return p->a_un.a_val;
should this just be under HAVE_AUX_VECTOR ? seems like we shouldn't
even bother defining/exporting dl_auxv at all if it's disabled. then
we wouldn't run into more latent problems like this at run time -- it
would be a build failure.
in looking at other uses of dl_auxv, why isn't _dl_sysdep_start an
issue too ? rtld.c:_dl_start_final always calls that, and that func
always walks GLRO(dl_auxv).
-mike
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] getauxval: fix crash on systems without HAVE_AUX_VECTOR
2016-04-02 17:30 ` Mike Frysinger
@ 2016-04-04 19:38 ` Roland McGrath
0 siblings, 0 replies; 5+ messages in thread
From: Roland McGrath @ 2016-04-04 19:38 UTC (permalink / raw)
To: Mike Frysinger; +Cc: GNU C Library, bug-hurd
> On 02 Apr 2016 12:57, Samuel Thibault wrote:
> > Systems without HAVE_AUX_VECTOR have GLRO(dl_auxv) == NULL, and
> > getauxval would thus crash.
>
> assuming this is for GNU/hurd
Yes.
> should this just be under HAVE_AUX_VECTOR ? seems like we shouldn't
> even bother defining/exporting dl_auxv at all if it's disabled. then
> we wouldn't run into more latent problems like this at run time -- it
> would be a build failure.
Agreed.
> in looking at other uses of dl_auxv, why isn't _dl_sysdep_start an
> issue too ? rtld.c:_dl_start_final always calls that, and that func
> always walks GLRO(dl_auxv).
You are looking at elf/dl-sysdep.c, not sysdeps/mach/hurd/dl-sysdep.c.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] getauxval: fix crash on systems without HAVE_AUX_VECTOR
2016-04-02 10:57 [PATCH] getauxval: fix crash on systems without HAVE_AUX_VECTOR Samuel Thibault
2016-04-02 17:30 ` Mike Frysinger
@ 2016-04-11 7:55 ` Markus Trippelsdorf
2016-04-11 8:28 ` Samuel Thibault
1 sibling, 1 reply; 5+ messages in thread
From: Markus Trippelsdorf @ 2016-04-11 7:55 UTC (permalink / raw)
To: GNU C Library, bug-hurd
On 2016.04.02 at 12:57 +0200, Samuel Thibault wrote:
> Systems without HAVE_AUX_VECTOR have GLRO(dl_auxv) == NULL, and
> getauxval would thus crash.
Your commit 0cdc5e930a breaks the build for me:
In file included from ../sysdeps/x86_64/ldsodefs.h:54:0,
from ../sysdeps/gnu/ldsodefs.h:46,
from ../sysdeps/unix/sysv/linux/ldsodefs.h:22,
from getauxval.c:20:
getauxval.c: In function â__getauxvalâ:
../sysdeps/generic/ldsodefs.h:439:21: error: â_dl_auxvâ undeclared (first use in this function)
# define GLRO(name) _##name
^
getauxval.c:34:12: note: in expansion of macro âGLROâ
for (p = GLRO(dl_auxv); p->a_type != AT_NULL; p++)
^~~~
../sysdeps/generic/ldsodefs.h:439:21: note: each undeclared identifier is reported only once for each function it appears in
# define GLRO(name) _##name
^
getauxval.c:34:12: note: in expansion of macro âGLROâ
for (p = GLRO(dl_auxv); p->a_type != AT_NULL; p++)
^~~~
../o-iterator.mk:9: recipe for target '/var/tmp/glibc-build/misc/getauxval.o' failed
--
Markus
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] getauxval: fix crash on systems without HAVE_AUX_VECTOR
2016-04-11 7:55 ` Markus Trippelsdorf
@ 2016-04-11 8:28 ` Samuel Thibault
0 siblings, 0 replies; 5+ messages in thread
From: Samuel Thibault @ 2016-04-11 8:28 UTC (permalink / raw)
To: Markus Trippelsdorf; +Cc: GNU C Library, bug-hurd
Hello,
Markus Trippelsdorf, on Mon 11 Apr 2016 09:55:12 +0200, wrote:
> On 2016.04.02 at 12:57 +0200, Samuel Thibault wrote:
> > Systems without HAVE_AUX_VECTOR have GLRO(dl_auxv) == NULL, and
> > getauxval would thus crash.
>
> Your commit 0cdc5e930a breaks the build for me:
Ah, sorry, part of the commit was missing indeed, now fixed.
Samuel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-04-11 8:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-02 10:57 [PATCH] getauxval: fix crash on systems without HAVE_AUX_VECTOR Samuel Thibault
2016-04-02 17:30 ` Mike Frysinger
2016-04-04 19:38 ` Roland McGrath
2016-04-11 7:55 ` Markus Trippelsdorf
2016-04-11 8:28 ` Samuel Thibault
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).