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
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
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.
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
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.
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.
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?
@@ -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