Remove gethostname from sysdeps/unix/syscalls.list

Message ID 20260926034052.524304-1-mattst88@gmail.com (mailing list archive)
State Committed
Commit 7b24791c7020adee5621ecb1e414a2f70e1da210
Delegated to: Adhemerval Zanella Netto
Headers
Series Remove gethostname from sysdeps/unix/syscalls.list |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
redhat-pt-bot/TryBot-32bit success Build for i686
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Test passed

Commit Message

Matt Turner Sept. 26, 2026, 3:40 a.m. UTC
  Commit 9d7d648088 ("alpha: Use the generic gethostname") removed the
alpha gethostname.c to use sysdeps/posix/gethostname.c, but
sysdeps/unix precedes sysdeps/posix and its syscalls.list has a
gethostname entry. alpha is the only Linux target defining
__NR_gethostname, so it now gets a raw syscall wrapper. The kernel
truncates the name and returns 0, so a too-small buffer is no longer
an error:

  tst-gethostname.c:95: not true: gethostname (hostname, HOST_NAME_MAX) == -1

nss/test-netdb crashes because gethostname (NULL, 0) now succeeds.
qemu-user does not show this; it implements the syscall with the
host's gethostname.

No other target uses the entry: other Linux targets lack
__NR_gethostname and Hurd has its own gethostname.c.
---
 sysdeps/unix/syscalls.list | 1 -
 1 file changed, 1 deletion(-)
  

Comments

Andreas Schwab Sept. 26, 2026, 9:24 a.m. UTC | #1
On Sep 25 2026, Matt Turner wrote:

> Commit 9d7d648088 ("alpha: Use the generic gethostname") removed the
> alpha gethostname.c to use sysdeps/posix/gethostname.c, but
> sysdeps/unix precedes sysdeps/posix and its syscalls.list has a
> gethostname entry. alpha is the only Linux target defining
> __NR_gethostname, so it now gets a raw syscall wrapper. The kernel
> truncates the name and returns 0, so a too-small buffer is no longer
> an error:

That's a conforming implemention of gethostname.
  
Adhemerval Zanella Netto Sept. 29, 2026, 12:42 p.m. UTC | #2
On 26/09/26 00:40, Matt Turner wrote:
> Commit 9d7d648088 ("alpha: Use the generic gethostname") removed the
> alpha gethostname.c to use sysdeps/posix/gethostname.c, but
> sysdeps/unix precedes sysdeps/posix and its syscalls.list has a
> gethostname entry. alpha is the only Linux target defining
> __NR_gethostname, so it now gets a raw syscall wrapper. The kernel
> truncates the name and returns 0, so a too-small buffer is no longer
> an error:
> 
>   tst-gethostname.c:95: not true: gethostname (hostname, HOST_NAME_MAX) == -1
> 
> nss/test-netdb crashes because gethostname (NULL, 0) now succeeds.
> qemu-user does not show this; it implements the syscall with the
> host's gethostname.
> 
> No other target uses the entry: other Linux targets lack
> __NR_gethostname and Hurd has its own gethostname.c.

Even though it is a conforming implementation, as Andreas has pointed out,
there is no clear advantage of making alpha an outlier.

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  sysdeps/unix/syscalls.list | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git ./sysdeps/unix/syscalls.list ./sysdeps/unix/syscalls.list
> index 10bd409eef..67c82783a1 100644
> --- ./sysdeps/unix/syscalls.list
> +++ ./sysdeps/unix/syscalls.list
> @@ -24,7 +24,6 @@ getdomain	-	getdomainname	i:si	getdomainname
>  getgid		-	getgid		Ei:	__getgid	getgid
>  getgroups	-	getgroups	i:ip	__getgroups	getgroups
>  gethostid	-	gethostid	i:	gethostid
> -gethostname	-	gethostname	i:bn	__gethostname	gethostname
>  getpeername	-	getpeername	i:ibN	__getpeername	getpeername
>  getpid		-	getpid		Ei:	__getpid	getpid
>  getpriority	-	getpriority	i:ii	__getpriority	getpriority
  
Matt Turner Sept. 30, 2026, 1:06 a.m. UTC | #3
On Sat, Sep 26, 2026 at 5:24 AM Andreas Schwab <schwab@linux-m68k.org> wrote:
>
> On Sep 25 2026, Matt Turner wrote:
>
> > Commit 9d7d648088 ("alpha: Use the generic gethostname") removed the
> > alpha gethostname.c to use sysdeps/posix/gethostname.c, but
> > sysdeps/unix precedes sysdeps/posix and its syscalls.list has a
> > gethostname entry. alpha is the only Linux target defining
> > __NR_gethostname, so it now gets a raw syscall wrapper. The kernel
> > truncates the name and returns 0, so a too-small buffer is no longer
> > an error:
>
> That's a conforming implemention of gethostname.

Interesting, thank you. I did not know that. So I suppose our test is
a bit too strict.
  
Matt Turner Sept. 30, 2026, 1:07 a.m. UTC | #4
On Tue, Sep 29, 2026 at 8:42 AM Adhemerval Zanella Netto
<adhemerval.zanella@linaro.org> wrote:
>
>
>
> On 26/09/26 00:40, Matt Turner wrote:
> > Commit 9d7d648088 ("alpha: Use the generic gethostname") removed the
> > alpha gethostname.c to use sysdeps/posix/gethostname.c, but
> > sysdeps/unix precedes sysdeps/posix and its syscalls.list has a
> > gethostname entry. alpha is the only Linux target defining
> > __NR_gethostname, so it now gets a raw syscall wrapper. The kernel
> > truncates the name and returns 0, so a too-small buffer is no longer
> > an error:
> >
> >   tst-gethostname.c:95: not true: gethostname (hostname, HOST_NAME_MAX) == -1
> >
> > nss/test-netdb crashes because gethostname (NULL, 0) now succeeds.
> > qemu-user does not show this; it implements the syscall with the
> > host's gethostname.
> >
> > No other target uses the entry: other Linux targets lack
> > __NR_gethostname and Hurd has its own gethostname.c.
>
> Even though it is a conforming implementation, as Andreas has pointed out,
> there is no clear advantage of making alpha an outlier.

Thank you. Agreed, that makes sense to me.
  
Matt Turner Oct. 8, 2026, 4:40 a.m. UTC | #5
On Tue, Sep 29, 2026 at 9:07 PM Matt Turner <mattst88@gmail.com> wrote:
>
> On Tue, Sep 29, 2026 at 8:42 AM Adhemerval Zanella Netto
> <adhemerval.zanella@linaro.org> wrote:
> >
> >
> >
> > On 26/09/26 00:40, Matt Turner wrote:
> > > Commit 9d7d648088 ("alpha: Use the generic gethostname") removed the
> > > alpha gethostname.c to use sysdeps/posix/gethostname.c, but
> > > sysdeps/unix precedes sysdeps/posix and its syscalls.list has a
> > > gethostname entry. alpha is the only Linux target defining
> > > __NR_gethostname, so it now gets a raw syscall wrapper. The kernel
> > > truncates the name and returns 0, so a too-small buffer is no longer
> > > an error:
> > >
> > >   tst-gethostname.c:95: not true: gethostname (hostname, HOST_NAME_MAX) == -1
> > >
> > > nss/test-netdb crashes because gethostname (NULL, 0) now succeeds.
> > > qemu-user does not show this; it implements the syscall with the
> > > host's gethostname.
> > >
> > > No other target uses the entry: other Linux targets lack
> > > __NR_gethostname and Hurd has its own gethostname.c.
> >
> > Even though it is a conforming implementation, as Andreas has pointed out,
> > there is no clear advantage of making alpha an outlier.
>
> Thank you. Agreed, that makes sense to me.

Can someone push this for me?
  

Patch

diff --git ./sysdeps/unix/syscalls.list ./sysdeps/unix/syscalls.list
index 10bd409eef..67c82783a1 100644
--- ./sysdeps/unix/syscalls.list
+++ ./sysdeps/unix/syscalls.list
@@ -24,7 +24,6 @@  getdomain	-	getdomainname	i:si	getdomainname
 getgid		-	getgid		Ei:	__getgid	getgid
 getgroups	-	getgroups	i:ip	__getgroups	getgroups
 gethostid	-	gethostid	i:	gethostid
-gethostname	-	gethostname	i:bn	__gethostname	gethostname
 getpeername	-	getpeername	i:ibN	__getpeername	getpeername
 getpid		-	getpid		Ei:	__getpid	getpid
 getpriority	-	getpriority	i:ii	__getpriority	getpriority