public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [hurd, commited] hurd: Use __trivfs_server_name instead of trivfs_server_name
@ 2022-01-01 16:53 Samuel Thibault
  2022-01-01 17:27 ` Florian Weimer
  0 siblings, 1 reply; 7+ messages in thread
From: Samuel Thibault @ 2022-01-01 16:53 UTC (permalink / raw)
  To: libc-alpha; +Cc: Samuel Thibault, commit-hurd

The latter violates namespace contraints
---
 sysdeps/mach/hurd/getrandom.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/sysdeps/mach/hurd/getrandom.c b/sysdeps/mach/hurd/getrandom.c
index 24f9ac60f7..76f2e900d2 100644
--- a/sysdeps/mach/hurd/getrandom.c
+++ b/sysdeps/mach/hurd/getrandom.c
@@ -21,7 +21,7 @@
 #include <unistd.h>
 #include <not-cancel.h>
 
-extern char *trivfs_server_name __attribute__((weak));
+extern char *__trivfs_server_name __attribute__((weak));
 
 /* Write up to LENGTH bytes of randomness starting at BUFFER.
    Return the number of bytes written, or -1 on error.  */
@@ -33,14 +33,14 @@ __getrandom (void *buffer, size_t length, unsigned int flags)
   size_t amount_read;
   int fd;
 
-  if (&trivfs_server_name && trivfs_server_name
-      && trivfs_server_name[0] == 'r'
-      && trivfs_server_name[1] == 'a'
-      && trivfs_server_name[2] == 'n'
-      && trivfs_server_name[3] == 'd'
-      && trivfs_server_name[4] == 'o'
-      && trivfs_server_name[5] == 'm'
-      && trivfs_server_name[6] == '\0')
+  if (&__trivfs_server_name && __trivfs_server_name
+      && __trivfs_server_name[0] == 'r'
+      && __trivfs_server_name[1] == 'a'
+      && __trivfs_server_name[2] == 'n'
+      && __trivfs_server_name[3] == 'd'
+      && __trivfs_server_name[4] == 'o'
+      && __trivfs_server_name[5] == 'm'
+      && __trivfs_server_name[6] == '\0')
     /* We are random, don't try to read ourselves!  */
     return length;
 
-- 
2.34.1


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

* Re: [hurd, commited] hurd: Use __trivfs_server_name instead of trivfs_server_name
  2022-01-01 16:53 [hurd, commited] hurd: Use __trivfs_server_name instead of trivfs_server_name Samuel Thibault
@ 2022-01-01 17:27 ` Florian Weimer
  2022-01-01 17:41   ` Samuel Thibault
  0 siblings, 1 reply; 7+ messages in thread
From: Florian Weimer @ 2022-01-01 17:27 UTC (permalink / raw)
  To: Samuel Thibault; +Cc: libc-alpha, commit-hurd

* Samuel Thibault:

> The latter violates namespace contraints
> ---
>  sysdeps/mach/hurd/getrandom.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/sysdeps/mach/hurd/getrandom.c b/sysdeps/mach/hurd/getrandom.c
> index 24f9ac60f7..76f2e900d2 100644
> --- a/sysdeps/mach/hurd/getrandom.c
> +++ b/sysdeps/mach/hurd/getrandom.c
> @@ -21,7 +21,7 @@
>  #include <unistd.h>
>  #include <not-cancel.h>
>  
> -extern char *trivfs_server_name __attribute__((weak));
> +extern char *__trivfs_server_name __attribute__((weak));
>  
>  /* Write up to LENGTH bytes of randomness starting at BUFFER.
>     Return the number of bytes written, or -1 on error.  */
> @@ -33,14 +33,14 @@ __getrandom (void *buffer, size_t length, unsigned int flags)
>    size_t amount_read;
>    int fd;
>  
> -  if (&trivfs_server_name && trivfs_server_name
> -      && trivfs_server_name[0] == 'r'
> -      && trivfs_server_name[1] == 'a'
> -      && trivfs_server_name[2] == 'n'
> -      && trivfs_server_name[3] == 'd'
> -      && trivfs_server_name[4] == 'o'
> -      && trivfs_server_name[5] == 'm'
> -      && trivfs_server_name[6] == '\0')
> +  if (&__trivfs_server_name && __trivfs_server_name
> +      && __trivfs_server_name[0] == 'r'
> +      && __trivfs_server_name[1] == 'a'
> +      && __trivfs_server_name[2] == 'n'
> +      && __trivfs_server_name[3] == 'd'
> +      && __trivfs_server_name[4] == 'o'
> +      && __trivfs_server_name[5] == 'm'
> +      && __trivfs_server_name[6] == '\0')
>      /* We are random, don't try to read ourselves!  */
>      return length;

How does this work?  It's a new synbol name, so there's no definition,
so the weak reference is always null.

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

* Re: [hurd, commited] hurd: Use __trivfs_server_name instead of trivfs_server_name
  2022-01-01 17:27 ` Florian Weimer
@ 2022-01-01 17:41   ` Samuel Thibault
  2022-01-01 18:48     ` Florian Weimer
  0 siblings, 1 reply; 7+ messages in thread
From: Samuel Thibault @ 2022-01-01 17:41 UTC (permalink / raw)
  To: bug-hurd; +Cc: commit-hurd, libc-alpha

Florian Weimer, le sam. 01 janv. 2022 18:27:49 +0100, a ecrit:
> > @@ -33,14 +33,14 @@ __getrandom (void *buffer, size_t length, unsigned int flags)
> >    size_t amount_read;
> >    int fd;
> >  
> > -  if (&trivfs_server_name && trivfs_server_name
> > -      && trivfs_server_name[0] == 'r'
> > -      && trivfs_server_name[1] == 'a'
> > -      && trivfs_server_name[2] == 'n'
> > -      && trivfs_server_name[3] == 'd'
> > -      && trivfs_server_name[4] == 'o'
> > -      && trivfs_server_name[5] == 'm'
> > -      && trivfs_server_name[6] == '\0')
> > +  if (&__trivfs_server_name && __trivfs_server_name
> > +      && __trivfs_server_name[0] == 'r'
> > +      && __trivfs_server_name[1] == 'a'
> > +      && __trivfs_server_name[2] == 'n'
> > +      && __trivfs_server_name[3] == 'd'
> > +      && __trivfs_server_name[4] == 'o'
> > +      && __trivfs_server_name[5] == 'm'
> > +      && __trivfs_server_name[6] == '\0')
> >      /* We are random, don't try to read ourselves!  */
> >      return length;
> 
> How does this work?  It's a new synbol name, so there's no definition,
> so the weak reference is always null.

It is peeking it from the program.

Basically the problem is that the random translator uses glibc, whose
malloc implementation started using /dev/random in glibc 2.34, thus
reading itself.

Samuel

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

* Re: [hurd, commited] hurd: Use __trivfs_server_name instead of trivfs_server_name
  2022-01-01 17:41   ` Samuel Thibault
@ 2022-01-01 18:48     ` Florian Weimer
  2022-01-01 18:58       ` Samuel Thibault
  0 siblings, 1 reply; 7+ messages in thread
From: Florian Weimer @ 2022-01-01 18:48 UTC (permalink / raw)
  To: bug-hurd; +Cc: commit-hurd, libc-alpha

* Samuel Thibault via Libc-alpha:

> Florian Weimer, le sam. 01 janv. 2022 18:27:49 +0100, a ecrit:
>> > @@ -33,14 +33,14 @@ __getrandom (void *buffer, size_t length, unsigned int flags)
>> >    size_t amount_read;
>> >    int fd;
>> >  
>> > -  if (&trivfs_server_name && trivfs_server_name
>> > -      && trivfs_server_name[0] == 'r'
>> > -      && trivfs_server_name[1] == 'a'
>> > -      && trivfs_server_name[2] == 'n'
>> > -      && trivfs_server_name[3] == 'd'
>> > -      && trivfs_server_name[4] == 'o'
>> > -      && trivfs_server_name[5] == 'm'
>> > -      && trivfs_server_name[6] == '\0')
>> > +  if (&__trivfs_server_name && __trivfs_server_name
>> > +      && __trivfs_server_name[0] == 'r'
>> > +      && __trivfs_server_name[1] == 'a'
>> > +      && __trivfs_server_name[2] == 'n'
>> > +      && __trivfs_server_name[3] == 'd'
>> > +      && __trivfs_server_name[4] == 'o'
>> > +      && __trivfs_server_name[5] == 'm'
>> > +      && __trivfs_server_name[6] == '\0')
>> >      /* We are random, don't try to read ourselves!  */
>> >      return length;
>> 
>> How does this work?  It's a new synbol name, so there's no definition,
>> so the weak reference is always null.
>
> It is peeking it from the program.
>
> Basically the problem is that the random translator uses glibc, whose
> malloc implementation started using /dev/random in glibc 2.34, thus
> reading itself.

I still don't understand.  Why isn't the condition always false?

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

* Re: [hurd, commited] hurd: Use __trivfs_server_name instead of trivfs_server_name
  2022-01-01 18:48     ` Florian Weimer
@ 2022-01-01 18:58       ` Samuel Thibault
  2022-01-01 19:02         ` Florian Weimer
  0 siblings, 1 reply; 7+ messages in thread
From: Samuel Thibault @ 2022-01-01 18:58 UTC (permalink / raw)
  To: Florian Weimer; +Cc: bug-hurd, commit-hurd, libc-alpha

Florian Weimer, le sam. 01 janv. 2022 19:48:21 +0100, a ecrit:
> * Samuel Thibault via Libc-alpha:
> >> > +  if (&__trivfs_server_name && __trivfs_server_name
> >> > +      && __trivfs_server_name[0] == 'r'
> >> > +      && __trivfs_server_name[1] == 'a'
> >> > +      && __trivfs_server_name[2] == 'n'
> >> > +      && __trivfs_server_name[3] == 'd'
> >> > +      && __trivfs_server_name[4] == 'o'
> >> > +      && __trivfs_server_name[5] == 'm'
> >> > +      && __trivfs_server_name[6] == '\0')
> >> >      /* We are random, don't try to read ourselves!  */
> >> >      return length;
> >> 
> >> How does this work?  It's a new synbol name, so there's no definition,
> >> so the weak reference is always null.
> >
> > It is peeking it from the program.
> >
> > Basically the problem is that the random translator uses glibc, whose
> > malloc implementation started using /dev/random in glibc 2.34, thus
> > reading itself.
> 
> I still don't understand.  Why isn't the condition always false?

The definition is in the random translator, which exports it in its
dynamic symbol table.

Samuel

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

* Re: [hurd, commited] hurd: Use __trivfs_server_name instead of trivfs_server_name
  2022-01-01 18:58       ` Samuel Thibault
@ 2022-01-01 19:02         ` Florian Weimer
  2022-01-01 19:11           ` Samuel Thibault
  0 siblings, 1 reply; 7+ messages in thread
From: Florian Weimer @ 2022-01-01 19:02 UTC (permalink / raw)
  To: bug-hurd; +Cc: commit-hurd, libc-alpha

* Samuel Thibault:

> Florian Weimer, le sam. 01 janv. 2022 19:48:21 +0100, a ecrit:
>> * Samuel Thibault via Libc-alpha:
>> >> > +  if (&__trivfs_server_name && __trivfs_server_name
>> >> > +      && __trivfs_server_name[0] == 'r'
>> >> > +      && __trivfs_server_name[1] == 'a'
>> >> > +      && __trivfs_server_name[2] == 'n'
>> >> > +      && __trivfs_server_name[3] == 'd'
>> >> > +      && __trivfs_server_name[4] == 'o'
>> >> > +      && __trivfs_server_name[5] == 'm'
>> >> > +      && __trivfs_server_name[6] == '\0')
>> >> >      /* We are random, don't try to read ourselves!  */
>> >> >      return length;
>> >> 
>> >> How does this work?  It's a new synbol name, so there's no definition,
>> >> so the weak reference is always null.
>> >
>> > It is peeking it from the program.
>> >
>> > Basically the problem is that the random translator uses glibc, whose
>> > malloc implementation started using /dev/random in glibc 2.34, thus
>> > reading itself.
>> 
>> I still don't understand.  Why isn't the condition always false?
>
> The definition is in the random translator, which exports it in its
> dynamic symbol table.

Oh, so there is a companion patch that is not reflected in the glibc
sources?

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

* Re: [hurd, commited] hurd: Use __trivfs_server_name instead of trivfs_server_name
  2022-01-01 19:02         ` Florian Weimer
@ 2022-01-01 19:11           ` Samuel Thibault
  0 siblings, 0 replies; 7+ messages in thread
From: Samuel Thibault @ 2022-01-01 19:11 UTC (permalink / raw)
  To: Florian Weimer; +Cc: bug-hurd, commit-hurd, libc-alpha

Florian Weimer, le sam. 01 janv. 2022 20:02:12 +0100, a ecrit:
> * Samuel Thibault:
> 
> > Florian Weimer, le sam. 01 janv. 2022 19:48:21 +0100, a ecrit:
> >> * Samuel Thibault via Libc-alpha:
> >> >> > +  if (&__trivfs_server_name && __trivfs_server_name
> >> >> > +      && __trivfs_server_name[0] == 'r'
> >> >> > +      && __trivfs_server_name[1] == 'a'
> >> >> > +      && __trivfs_server_name[2] == 'n'
> >> >> > +      && __trivfs_server_name[3] == 'd'
> >> >> > +      && __trivfs_server_name[4] == 'o'
> >> >> > +      && __trivfs_server_name[5] == 'm'
> >> >> > +      && __trivfs_server_name[6] == '\0')
> >> >> >      /* We are random, don't try to read ourselves!  */
> >> >> >      return length;
> >> >> 
> >> >> How does this work?  It's a new synbol name, so there's no definition,
> >> >> so the weak reference is always null.
> >> >
> >> > It is peeking it from the program.
> >> >
> >> > Basically the problem is that the random translator uses glibc, whose
> >> > malloc implementation started using /dev/random in glibc 2.34, thus
> >> > reading itself.
> >> 
> >> I still don't understand.  Why isn't the condition always false?
> >
> > The definition is in the random translator, which exports it in its
> > dynamic symbol table.
> 
> Oh, so there is a companion patch that is not reflected in the glibc
> sources?

Yes, it's there:

http://git.savannah.gnu.org/cgit/hurd/hurd.git/commit/?id=8c5eb657ff196a31a3230652823221f3fe805d73

Samuel

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

end of thread, other threads:[~2022-01-01 19:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-01 16:53 [hurd, commited] hurd: Use __trivfs_server_name instead of trivfs_server_name Samuel Thibault
2022-01-01 17:27 ` Florian Weimer
2022-01-01 17:41   ` Samuel Thibault
2022-01-01 18:48     ` Florian Weimer
2022-01-01 18:58       ` Samuel Thibault
2022-01-01 19:02         ` Florian Weimer
2022-01-01 19:11           ` 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).